Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record status as string #2861

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions services/rfq/relayer/service/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"context"
"fmt"
"github.com/synapsecns/sanguine/services/rfq/relayer/reldb"

"github.com/cornelk/hashmap"
"github.com/synapsecns/sanguine/core/metrics"
Expand Down Expand Up @@ -32,7 +33,7 @@
statusCountGauge metric.Int64ObservableGauge
// statusCounts is used for metrics.
// status -> count
statusCounts *hashmap.Map[int, int]
statusCounts *hashmap.Map[reldb.QuoteRequestStatus, int]
// signer is the signer for signing transactions.
signer signer.Signer
}
Expand All @@ -41,7 +42,7 @@
or := otelRecorder{
metrics: meterHandler,
meter: meterHandler.Meter(meterName),
statusCounts: hashmap.New[int, int](),
statusCounts: hashmap.New[reldb.QuoteRequestStatus, int](),

Check warning on line 45 in services/rfq/relayer/service/otel.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/service/otel.go#L45

Added line #L45 was not covered by tests
signer: signer,
}

Expand All @@ -63,9 +64,10 @@
return nil
}

o.statusCounts.Range(func(status int, count int) bool {
o.statusCounts.Range(func(status reldb.QuoteRequestStatus, count int) bool {

Check warning on line 67 in services/rfq/relayer/service/otel.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/service/otel.go#L67

Added line #L67 was not covered by tests
opts := metric.WithAttributes(
attribute.Int("status", status),
attribute.Int("status_int", int(status.Int())),
attribute.String("status", status.String()),

Check warning on line 70 in services/rfq/relayer/service/otel.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/service/otel.go#L69-L70

Added lines #L69 - L70 were not covered by tests
attribute.String("wallet", o.signer.Address().Hex()),
)
observer.ObserveInt64(o.statusCountGauge, int64(count), opts)
Expand All @@ -76,7 +78,7 @@
return nil
}

// RecordStatusCounts records the request status count.
func (o *otelRecorder) RecordStatusCount(status, count int) {
// RecordStatusCount records the request status count.
func (o *otelRecorder) RecordStatusCount(status reldb.QuoteRequestStatus, count int) {

Check warning on line 82 in services/rfq/relayer/service/otel.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/service/otel.go#L82

Added line #L82 was not covered by tests
o.statusCounts.Set(status, count)
}
6 changes: 5 additions & 1 deletion services/rfq/relayer/service/otel_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/rfq/relayer/service/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
return fmt.Errorf("could not get status counts: %w", err)
}
for status, count := range statusCounts {
r.otelRecorder.RecordStatusCount(int(status.Int()), count)
r.otelRecorder.RecordStatusCount(status, count)

Check warning on line 391 in services/rfq/relayer/service/relayer.go

View check run for this annotation

Codecov / codecov/patch

services/rfq/relayer/service/relayer.go#L391

Added line #L391 was not covered by tests
}
}
}
Expand Down
Loading