Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dest tx hash before status/improve obversability #2888

Merged
merged 12 commits into from
Jul 19, 2024
6 changes: 5 additions & 1 deletion core/metrics/spanutils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package metrics

import "go.opentelemetry.io/otel/trace"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

// EndSpanWithErr ends a span and records an error if one is present.
func EndSpanWithErr(span trace.Span, err error) {
Expand All @@ -9,6 +12,7 @@ func EndSpanWithErr(span trace.Span, err error) {
}

if err != nil {
span.SetAttributes(attribute.String("span_error", err.Error()))
span.RecordError(err)
}

Expand Down
13 changes: 11 additions & 2 deletions services/rfq/relayer/service/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.opentelemetry.io/otel/trace"
)

var maxRPCRetryTime = 15 * time.Second
var maxRPCRetryTime = 30 * time.Second

// handleBridgeRequestedLog handles the BridgeRequestedLog event.
// Step 1: Seen
Expand Down Expand Up @@ -71,7 +71,16 @@ func (r *Relayer) handleBridgeRequestedLog(parentCtx context.Context, req *fastb
}

var bridgeTx fastbridge.IFastBridgeBridgeTransaction
call := func(ctx context.Context) error {
call := func(parentCtx context.Context) error {
trajan0x marked this conversation as resolved.
Show resolved Hide resolved
ctx, newSpan := r.metrics.Tracer().Start(parentCtx, "fetchBridgeTx", trace.WithAttributes(
attribute.String("transaction_id", hexutil.Encode(req.TransactionId[:])),
attribute.String("bridge_address", req.Raw.Address.String()),
))

defer func() {
metrics.EndSpanWithErr(newSpan, err)
}()

bridgeTx, err = fastBridge.GetBridgeTransaction(&bind.CallOpts{Context: ctx}, req.Request)
if err != nil {
return fmt.Errorf("could not get bridge transaction: %w", err)
Expand Down
Loading