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

feat: type safe metric labels #479

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Jan 3, 2024

See ChainSafe/lodestar#6201 for motivation / rationale

@nflaig nflaig requested a review from a team as a code owner January 3, 2024 10:06
@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (eb53ea9) 81.38% compared to head (59bd077) 81.37%.

Files Patch % Lines
src/metrics.ts 80.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #479      +/-   ##
==========================================
- Coverage   81.38%   81.37%   -0.02%     
==========================================
  Files          48       48              
  Lines       12275    12261      -14     
  Branches     1292     1292              
==========================================
- Hits         9990     9977      -13     
+ Misses       2285     2284       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -328,10 +315,9 @@ export function getMetrics (
labelNames: ['hit']
}),

asyncValidationDelayFromFirstSeenSec: register.histogram<{ topic: TopicLabel }>({
asyncValidationDelayFromFirstSeenSec: register.histogram({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label value is not set for this metric

this.asyncValidationDelayFromFirstSeenSec.observe((Date.now() - firstSeenTimestampMs) / 1000)

Topic might not be available when setting the metric hence I updated the type instead of updating the code and setting the topic.

@@ -883,9 +869,9 @@ export function getMetrics (
},

onDuplicateMsgDelivery (topicStr: TopicStr, deliveryDelayMs: number, isLateDelivery: boolean): void {
this.duplicateMsgDeliveryDelay.observe(deliveryDelayMs / 1000)
const topic = this.toTopic(topicStr)
this.duplicateMsgDeliveryDelay.observe({ topic }, deliveryDelayMs / 1000)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label was defined in type but not set. I'd assume this was just an oversight as topic is always available here.

@nflaig nflaig changed the title refactor: type safe metric labels feat: type safe metric labels Jan 3, 2024
@nflaig nflaig force-pushed the nflaig/type-safe-metric-labels branch from 086efa0 to 59bd077 Compare January 3, 2024 10:15
@nflaig nflaig changed the title feat: type safe metric labels chore: type safe metric labels Jan 3, 2024
@nflaig nflaig changed the title chore: type safe metric labels feat: type safe metric labels Jan 3, 2024
@wemeetagain wemeetagain merged commit 67c2a55 into master Jan 8, 2024
11 checks passed
@wemeetagain wemeetagain deleted the nflaig/type-safe-metric-labels branch January 8, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants