From 95e5f78162ef6dcab6eadea376f4202d2199aa5c Mon Sep 17 00:00:00 2001 From: Wondertan Date: Sat, 20 Apr 2024 21:06:20 +0200 Subject: [PATCH] record in traces --- fraudserv/service.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fraudserv/service.go b/fraudserv/service.go index c1e8cd9..53511cf 100644 --- a/fraudserv/service.go +++ b/fraudserv/service.go @@ -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)