From b215a0476664d8d72e9c63fbe99a885edfc1aa2c Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Wed, 4 Dec 2024 12:16:10 +0100 Subject: [PATCH] add metric attributes --- sync/metrics.go | 9 +++++++-- sync/sync_head.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sync/metrics.go b/sync/metrics.go index 2269a539..f60103b1 100644 --- a/sync/metrics.go +++ b/sync/metrics.go @@ -198,9 +198,14 @@ func (m *metrics) newSubjectiveHead(ctx context.Context, height uint64, timestam }) } -func (m *metrics) failedValidationAgainstSubjHead(ctx context.Context) { +func (m *metrics) failedValidationAgainstSubjHead(ctx context.Context, height int64, hash string) { m.observe(ctx, func(ctx context.Context) { - m.failedAgainstSubjHead.Add(ctx, 1) + m.failedAgainstSubjHead.Add(ctx, 1, + metric.WithAttributes( + attribute.Int64("height", height), + attribute.String("hash", hash), + ), + ) }) } diff --git a/sync/sync_head.go b/sync/sync_head.go index b2fc399f..50df75d6 100644 --- a/sync/sync_head.go +++ b/sync/sync_head.go @@ -241,7 +241,7 @@ func (s *Syncer[H]) verifySkipping(ctx context.Context, subjHead, networkHeader diff = networkHeader.Height() - subjHeight } - s.metrics.failedValidationAgainstSubjHead(ctx) + s.metrics.failedValidationAgainstSubjHead(ctx, int64(networkHeader.Height()), networkHeader.Hash().String()) log.Warnw("sync: header validation against subjHead", "height", networkHeader.Height(), "hash", networkHeader.Hash().String()) return fmt.Errorf("sync: header validation against subjHead height:%d hash:%x", networkHeader.Height(), networkHeader.Hash().String())