From 4716a8e82d834ea2cb31bb21d91a4780367ec404 Mon Sep 17 00:00:00 2001 From: Trajan0x Date: Tue, 9 Jul 2024 13:56:46 -0400 Subject: [PATCH] record string status --- services/rfq/relayer/service/otel.go | 14 ++++++++------ services/rfq/relayer/service/otel_generated.go | 6 +++++- services/rfq/relayer/service/relayer.go | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/services/rfq/relayer/service/otel.go b/services/rfq/relayer/service/otel.go index e59fb5b251..c078935114 100644 --- a/services/rfq/relayer/service/otel.go +++ b/services/rfq/relayer/service/otel.go @@ -3,6 +3,7 @@ package service import ( "context" "fmt" + "github.com/synapsecns/sanguine/services/rfq/relayer/reldb" "github.com/cornelk/hashmap" "github.com/synapsecns/sanguine/core/metrics" @@ -32,7 +33,7 @@ type otelRecorder struct { 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 } @@ -41,7 +42,7 @@ func newOtelRecorder(meterHandler metrics.Handler, signer signer.Signer) (_ iOte or := otelRecorder{ metrics: meterHandler, meter: meterHandler.Meter(meterName), - statusCounts: hashmap.New[int, int](), + statusCounts: hashmap.New[reldb.QuoteRequestStatus, int](), signer: signer, } @@ -63,9 +64,10 @@ func (o *otelRecorder) recordStatusCounts(_ context.Context, observer metric.Obs return nil } - o.statusCounts.Range(func(status int, count int) bool { + o.statusCounts.Range(func(status reldb.QuoteRequestStatus, count int) bool { opts := metric.WithAttributes( - attribute.Int("status", status), + attribute.Int("status_int", int(status.Int())), + attribute.String("status", status.String()), attribute.String("wallet", o.signer.Address().Hex()), ) observer.ObserveInt64(o.statusCountGauge, int64(count), opts) @@ -76,7 +78,7 @@ func (o *otelRecorder) recordStatusCounts(_ context.Context, observer metric.Obs 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) { o.statusCounts.Set(status, count) } diff --git a/services/rfq/relayer/service/otel_generated.go b/services/rfq/relayer/service/otel_generated.go index cd4b12b00c..cc63af1f85 100644 --- a/services/rfq/relayer/service/otel_generated.go +++ b/services/rfq/relayer/service/otel_generated.go @@ -2,8 +2,12 @@ package service +import ( + "github.com/synapsecns/sanguine/services/rfq/relayer/reldb" +) + // iOtelRecorder ... type iOtelRecorder interface { // RecordStatusCounts records the request status count. - RecordStatusCount(status, count int) + RecordStatusCount(status reldb.QuoteRequestStatus, count int) } diff --git a/services/rfq/relayer/service/relayer.go b/services/rfq/relayer/service/relayer.go index 9cc5de3578..5c6f8f8e44 100644 --- a/services/rfq/relayer/service/relayer.go +++ b/services/rfq/relayer/service/relayer.go @@ -388,7 +388,7 @@ func (r *Relayer) recordMetrics(ctx context.Context) (err error) { 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) } } }