From 4a0f2e7a8842e9b5f53ff22e54317d20ae99b7a4 Mon Sep 17 00:00:00 2001 From: vro <168573323+golangisfun123@users.noreply.github.com> Date: Fri, 20 Sep 2024 19:33:22 -0500 Subject: [PATCH] fix(promexporter): make spans better (#3164) * move the errors * [goreleaser] * fix v to w --- contrib/promexporter/exporters/exporter.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/promexporter/exporters/exporter.go b/contrib/promexporter/exporters/exporter.go index d67c42fd8d..df8d4af7e4 100644 --- a/contrib/promexporter/exporters/exporter.go +++ b/contrib/promexporter/exporters/exporter.go @@ -142,17 +142,17 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) { for _, pending := range e.cfg.DFKPending { if err := e.stuckHeroCountStats(ctx, common.HexToAddress(pending.Owner), pending.ChainName); err != nil { errs = append(errs, fmt.Errorf("could not get stuck hero count: %w", err)) + span.AddEvent("could not get stuck hero count") } - span.AddEvent("could not get stuck hero count") } for _, gasCheck := range e.cfg.SubmitterChecks { for _, chainID := range gasCheck.ChainIDs { if err := e.submitterStats(common.HexToAddress(gasCheck.Address), chainID, gasCheck.Name); err != nil { - errs = append(errs, fmt.Errorf("could setup metric: %w", err)) + errs = append(errs, fmt.Errorf("could not get submitter stats: %w", err)) + span.AddEvent("could not get submitter stats") } } - span.AddEvent("could get submitter stats") } for chainID := range e.cfg.BridgeChecks { @@ -161,7 +161,8 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) { return retry.WithBackoff(ctx, func(ctx context.Context) error { err := e.vpriceStats(ctx, chainID, token) if err != nil && !errors.Is(err, errPoolNotExist) { - errs = append(errs, fmt.Errorf("stuck hero stats: %w", err)) + errs = append(errs, fmt.Errorf("could not get vprice %w", err)) + span.AddEvent("could not get vprice stats") } return nil @@ -172,7 +173,7 @@ func (e *exporter) collectMetrics(parentCtx context.Context) (err error) { if len(errs) > 0 { span.AddEvent("could not collect metrics") - return fmt.Errorf("could not collect metrics: %v", errs) + return fmt.Errorf("could not collect metrics: %w", combineErrors(errs)) } return nil