Skip to content

Commit

Permalink
add metric attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Dec 4, 2024
1 parent 9734b93 commit b215a04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions sync/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
)
})
}

Expand Down
2 changes: 1 addition & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit b215a04

Please sign in to comment.