Skip to content

Commit

Permalink
Add extra logging to bridge response errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Dec 19, 2023
1 parent 0e5b219 commit dfe9ca4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 10 additions & 5 deletions core/services/ocrcommon/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,23 @@ func (e *EnhancedTelemetryService[T]) collectAndSend(trrs *pipeline.TaskRunResul
if trr.Task.Type() != pipeline.TaskTypeBridge {
continue
}
var bridgeName string
if b, is := trr.Task.(*pipeline.BridgeTask); is {
bridgeName = b.Name
}

if trr.Result.Error != nil {
e.lggr.Warnw(fmt.Sprintf("cannot get bridge response from bridge task, job %d, id %s", e.job.ID, trr.Task.DotID()), "err", trr.Result.Error)
e.lggr.Warnw(fmt.Sprintf("cannot get bridge response from bridge task, job=%d, id=%s, name=%q", e.job.ID, trr.Task.DotID(), bridgeName), "err", trr.Result.Error, "jobID", e.job.ID, "dotID", trr.Task.DotID(), "bridgeName", bridgeName)
continue
}
bridgeRawResponse, ok := trr.Result.Value.(string)
if !ok {
e.lggr.Warnf("cannot parse bridge response from bridge task, job %d, id %s: expected string, got: %v (type %T)", e.job.ID, trr.Task.DotID(), trr.Result.Value, trr.Result.Value)
e.lggr.Warnw(fmt.Sprintf("cannot parse bridge response from bridge task, job=%d, id=%s, name=%q: expected string, got: %v (type %T)", e.job.ID, trr.Task.DotID(), bridgeName, trr.Result.Value, trr.Result.Value), "jobID", e.job.ID, "dotID", trr.Task.DotID(), "bridgeName", bridgeName)
continue
}
eaTelem, err := parseEATelemetry([]byte(bridgeRawResponse))
if err != nil {
e.lggr.Warnw(fmt.Sprintf("cannot parse EA telemetry, job %d, id %s", e.job.ID, trr.Task.DotID()), "err", err)
e.lggr.Warnw(fmt.Sprintf("cannot parse EA telemetry, job=%d, id=%s, name=%q", e.job.ID, trr.Task.DotID(), bridgeName), "err", err, "jobID", e.job.ID, "dotID", trr.Task.DotID(), "bridgeName", bridgeName)
continue
}
value := e.getParsedValue(trrs, trr)
Expand Down Expand Up @@ -359,15 +363,16 @@ func (e *EnhancedTelemetryService[T]) collectMercuryEnhancedTelemetry(d Enhanced
continue
}
bridgeTask := trr.Task.(*pipeline.BridgeTask)
bridgeName := bridgeTask.Name

bridgeRawResponse, ok := trr.Result.Value.(string)
if !ok {
e.lggr.Warnf("cannot get bridge response from bridge task, job %d, id %s, expected string got %T", e.job.ID, trr.Task.DotID(), trr.Result.Value)
e.lggr.Warnw(fmt.Sprintf("cannot get bridge response from bridge task, job=%d, id=%s, name=%q, expected string got %T", e.job.ID, trr.Task.DotID(), bridgeName, trr.Result.Value), "jobID", e.job.ID, "dotID", trr.Task.DotID(), "bridgeName", bridgeName)
continue
}
eaTelem, err := parseEATelemetry([]byte(bridgeRawResponse))
if err != nil {
e.lggr.Warnw(fmt.Sprintf("cannot parse EA telemetry, job %d, id %s", e.job.ID, trr.Task.DotID()), "err", err)
e.lggr.Warnw(fmt.Sprintf("cannot parse EA telemetry, job=%d, id=%s, name=%q", e.job.ID, trr.Task.DotID(), bridgeName), "err", err, "jobID", e.job.ID, "dotID", trr.Task.DotID(), "bridgeName", bridgeName)
}

assetSymbol := e.getAssetSymbolFromRequestData(bridgeTask.RequestData)
Expand Down
10 changes: 9 additions & 1 deletion core/services/ocrcommon/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const bridgeResponse = `{
var trrs = pipeline.TaskRunResults{
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "test-bridge-1",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
},
Result: pipeline.Result{
Expand All @@ -62,6 +63,7 @@ var trrs = pipeline.TaskRunResults{
},
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "test-bridge-2",
BaseTask: pipeline.NewBaseTask(0, "ds2", nil, nil, 0),
},
Result: pipeline.Result{
Expand All @@ -78,6 +80,7 @@ var trrs = pipeline.TaskRunResults{
},
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "test-bridge-3",
BaseTask: pipeline.NewBaseTask(0, "ds3", nil, nil, 0),
},
Result: pipeline.Result{
Expand Down Expand Up @@ -390,6 +393,7 @@ func TestCollectAndSend(t *testing.T) {
var trrsMercuryV1 = pipeline.TaskRunResults{
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "link-usd-test-bridge-v1",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
RequestData: `{"data":{"to":"LINK","from":"USD"}}`,
},
Expand Down Expand Up @@ -426,6 +430,7 @@ var trrsMercuryV1 = pipeline.TaskRunResults{
var trrsMercuryV2 = pipeline.TaskRunResults{
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "link-usd-test-bridge-v2",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
RequestData: `{"data":{"to":"LINK","from":"USD"}}`,
},
Expand Down Expand Up @@ -477,6 +482,7 @@ func TestGetPricesFromResults(t *testing.T) {
trrs2 := pipeline.TaskRunResults{
pipeline.TaskRunResult{
Task: &pipeline.BridgeTask{
Name: "test-bridge-1",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
},
Result: pipeline.Result{
Expand Down Expand Up @@ -630,6 +636,7 @@ func TestCollectMercuryEnhancedTelemetryV1(t *testing.T) {
chTelem <- EnhancedTelemetryMercuryData{
TaskRunResults: pipeline.TaskRunResults{
pipeline.TaskRunResult{Task: &pipeline.BridgeTask{
Name: "test-mercury-bridge-1",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
},
Result: pipeline.Result{
Expand Down Expand Up @@ -657,7 +664,7 @@ func TestCollectMercuryEnhancedTelemetryV1(t *testing.T) {

wg.Wait()
require.Equal(t, 2, logs.Len())
require.Contains(t, logs.All()[0].Message, "cannot get bridge response from bridge task")
require.Contains(t, logs.All()[0].Message, `cannot get bridge response from bridge task, job=0, id=ds1, name="test-mercury-bridge-1"`)
require.Contains(t, logs.All()[1].Message, "cannot parse EA telemetry")
chDone <- struct{}{}
}
Expand Down Expand Up @@ -744,6 +751,7 @@ func TestCollectMercuryEnhancedTelemetryV2(t *testing.T) {
chTelem <- EnhancedTelemetryMercuryData{
TaskRunResults: pipeline.TaskRunResults{
pipeline.TaskRunResult{Task: &pipeline.BridgeTask{
Name: "test-mercury-bridge-2",
BaseTask: pipeline.NewBaseTask(0, "ds1", nil, nil, 0),
},
Result: pipeline.Result{
Expand Down

0 comments on commit dfe9ca4

Please sign in to comment.