Skip to content

Commit

Permalink
feat: add msg.String() to all msg related events
Browse files Browse the repository at this point in the history
  • Loading branch information
P1sar committed Aug 10, 2023
1 parent 625faa3 commit b7a1281
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions chains/evm/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (e *Executor) Execute(ctx context.Context, msgs []*message.Message) error {

proposals := make([]*chains.Proposal, 0)
for _, m := range msgs {
logger.Info().Str("msg.id", m.ID()).Msgf("Message to execute %s", m.String())
span.AddEvent("Message to execute received", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
logger.Debug().Str("msg.id", m.ID()).Msgf("Message to execute %s", m.String())
span.AddEvent("Message to execute received", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
prop, err := e.mh.HandleMessage(m)
if err != nil {
return fmt.Errorf("failed to handle message %s with error: %w", m.String(), err)
Expand All @@ -97,11 +97,11 @@ func (e *Executor) Execute(ctx context.Context, msgs []*message.Message) error {
}
if isExecuted {
logger.Info().Str("msg.id", m.ID()).Msgf("Message already executed %s", m.String())
span.AddEvent("Message already executed", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
span.AddEvent("Message already executed", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
continue
}
logger.Info().Str("msg.id", m.ID()).Msgf("Executing message %s", m.String())
span.AddEvent("Executing message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
span.AddEvent("Executing message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
proposals = append(proposals, evmProposal)
}
if len(proposals) == 0 {
Expand Down Expand Up @@ -174,15 +174,15 @@ func (e *Executor) watchExecution(ctx context.Context, cancelExecution context.C
return err
}

logger.Info().Str("SessionID", sessionID).Msgf("Sent proposals execution with hash: %s", hash)
logger.Debug().Str("SessionID", sessionID).Msgf("Sent proposals execution with hash: %s", hash)
}
case <-ticker.C:
{
if !e.areProposalsExecuted(proposals, sessionID) {
continue
}

logger.Info().Str("SessionID", sessionID).Msgf("Successfully executed proposals")
logger.Debug().Str("SessionID", sessionID).Msgf("Successfully executed proposals")
span.AddEvent("Proposals executed", traceapi.WithAttributes(attribute.String("tss.session.id", sessionID)))
return 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 @@ -98,7 +98,7 @@ func (eh *DepositEventHandler) HandleEvent(
}
logger.Info().Str("msg.id", m.ID()).Msgf("Resolved deposit message %s in block range: %s-%s", m.String(), startBlock.String(), endBlock.String())
// Events should eventually replace most of the logs
span.AddEvent("Resolved deposit message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
span.AddEvent("Resolved deposit message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
if m.Type == PermissionlessGenericTransfer {
msgChan <- []*message.Message{m}
return
Expand Down
8 changes: 4 additions & 4 deletions chains/substrate/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (e *Executor) Execute(ctx context.Context, msgs []*message.Message) error {

proposals := make([]*chains.Proposal, 0)
for _, m := range msgs {
logger.Info().Str("msg.id", m.ID()).Msgf("Message to execute %s", m.String())
span.AddEvent("Message to execute received", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
logger.Debug().Str("msg.id", m.ID()).Msgf("Message to execute %s", m.String())
span.AddEvent("Message to execute received", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
prop, err := e.mh.HandleMessage(m)
if err != nil {
return fmt.Errorf("failed to handle message %s with error: %w", m.String(), err)
Expand All @@ -105,8 +105,8 @@ func (e *Executor) Execute(ctx context.Context, msgs []*message.Message) error {
return err
}
if isExecuted {
logger.Info().Str("msg.id", m.ID()).Msgf("Message already executed %s", m.String())
span.AddEvent("Message already executed", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
logger.Debug().Str("msg.id", m.ID()).Msgf("Message already executed %s", m.String())
span.AddEvent("Message already executed", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
continue
}

Expand Down
4 changes: 2 additions & 2 deletions chains/substrate/listener/event-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func (eh *FungibleTransferEventHandler) HandleEvents(ctx context.Context, evts [
return
}

logger.Info().Str("msg.id", m.ID()).Msgf("Resolved deposit message %s", m.String())
span.AddEvent("Resolved message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.type", string(m.Type))))
logger.Debug().Str("msg.id", m.ID()).Msgf("Resolved deposit message %s", m.String())
span.AddEvent("Resolved message", traceapi.WithAttributes(attribute.String("msg.id", m.ID()), attribute.String("msg.full", m.String())))
domainDeposits[m.Destination] = append(domainDeposits[m.Destination], m)
}(*evt)
}
Expand Down

0 comments on commit b7a1281

Please sign in to comment.