Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
fix: fix message id to be more unique and update logs traceid attribu…
Browse files Browse the repository at this point in the history
…te name (#347)

* fix: make msg.id to be unique and now include source-destination-nonce

* fix: change trace_id logs attr to dd.trace_id for DataDog parsing
  • Loading branch information
P1sar committed Aug 28, 2023
1 parent 1a13e1b commit 0bc1f20
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chains/evm/calls/events/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (l *Listener) FetchDeposits(ctx context.Context, contractAddress common.Add
ctxWithSpan, span := otel.Tracer("relayer-core").Start(ctx, "relayer.core.Listener.FetchDeposits")
defer span.End()
span.SetAttributes(attribute.String("startBlock", startBlock.String()), attribute.String("endBlock", endBlock.String()))
logger := log.With().Str("trace_id", span.SpanContext().TraceID().String()).Logger()
logger := log.With().Str("dd.trace_id", span.SpanContext().TraceID().String()).Logger()

logs, err := l.client.FetchEventLogs(ctxWithSpan, contractAddress, string(DepositSig), startBlock, endBlock)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion chains/evm/listener/event-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (eh *DepositEventHandler) HandleEvent(ctx context.Context, startBlock *big.
ctxWithSpan, span := otel.Tracer("relayer-core").Start(ctx, "relayer.core.DepositEventHandler.HandleEvent")
defer span.End()
span.SetAttributes(attribute.String("startBlock", startBlock.String()), attribute.String("endBlock", endBlock.String()))
logger := log.With().Str("trace_id", span.SpanContext().TraceID().String()).Logger()
logger := log.With().Str("dd.trace_id", span.SpanContext().TraceID().String()).Logger()
deposits, err := eh.eventListener.FetchDeposits(ctxWithSpan, eh.bridgeAddress, startBlock, endBlock)
if err != nil {
span.SetStatus(codes.Error, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion chains/evm/listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (l *EVMListener) ListenToEvents(ctx context.Context, startBlock *big.Int, m
return
default:
ctxWithSpan, span := otel.Tracer("relayer-core").Start(ctx, "relayer.core.EVMListener.ListenToEvents")
logger := l.log.With().Str("trace_id", span.SpanContext().TraceID().String()).Logger()
logger := l.log.With().Str("dd.trace_id", span.SpanContext().TraceID().String()).Logger()
head, err := l.client.LatestBlock()
if err != nil {
logger.Error().Err(err).Msg("Unable to get latest block")
Expand Down
2 changes: 1 addition & 1 deletion relayer/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ func NewMessage(
}

func (m Message) ID() string {
return strconv.FormatInt(int64(m.Source), 10) + "-" + strconv.FormatInt(int64(m.DepositNonce), 10)
return strconv.FormatInt(int64(m.Source), 10) + "-" + strconv.FormatInt(int64(m.Destination), 10) + "-" + strconv.FormatInt(int64(m.DepositNonce), 10)
}

0 comments on commit 0bc1f20

Please sign in to comment.