Skip to content

Commit

Permalink
fix(promexporter): make spans better (#3164)
Browse files Browse the repository at this point in the history
* move the errors

* [goreleaser]

* fix v to w
  • Loading branch information
golangisfun123 authored Sep 21, 2024
1 parent dd67210 commit 4a0f2e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions contrib/promexporter/exporters/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check warning on line 145 in contrib/promexporter/exporters/exporter.go

View check run for this annotation

Codecov / codecov/patch

contrib/promexporter/exporters/exporter.go#L145

Added line #L145 was not covered by tests
}
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")

Check warning on line 153 in contrib/promexporter/exporters/exporter.go

View check run for this annotation

Codecov / codecov/patch

contrib/promexporter/exporters/exporter.go#L152-L153

Added lines #L152 - L153 were not covered by tests
}
}
span.AddEvent("could get submitter stats")
}

for chainID := range e.cfg.BridgeChecks {
Expand All @@ -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")

Check warning on line 165 in contrib/promexporter/exporters/exporter.go

View check run for this annotation

Codecov / codecov/patch

contrib/promexporter/exporters/exporter.go#L164-L165

Added lines #L164 - L165 were not covered by tests
}

return nil
Expand All @@ -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))

Check warning on line 176 in contrib/promexporter/exporters/exporter.go

View check run for this annotation

Codecov / codecov/patch

contrib/promexporter/exporters/exporter.go#L176

Added line #L176 was not covered by tests
}

return nil
Expand Down

0 comments on commit 4a0f2e7

Please sign in to comment.