Skip to content

Commit

Permalink
record in traces
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Apr 20, 2024
1 parent 3298b67 commit 95e5f78
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fraudserv/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,21 @@ func (f *ProofService[H]) processIncoming(
from peer.ID,
msg *pubsub.Message,
) (res pubsub.ValidationResult) {
defer func() {
err := recover()
if err != nil {
log.Errorf("PANIC while processing a proof: %s", err)
res = pubsub.ValidationReject
}
}()

ctx, span := tracer.Start(ctx, "process_proof", trace.WithAttributes(
attribute.String("proof_type", string(proofType)),
))
defer span.End()

defer func() {
r := recover()
if r != nil {
err := fmt.Errorf("PANIC while processing a proof: %s", r)
log.Error(err)
span.RecordError(err)
res = pubsub.ValidationReject
}
}()

// unmarshal message to the Proof.
// Peer will be added to black list if unmarshalling fails.
proof, err := f.unmarshal.Unmarshal(proofType, msg.Data)
Expand Down

0 comments on commit 95e5f78

Please sign in to comment.