-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
chore: Prometheus metrics refactor #8484
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
src/lib/metrics-gauge.ts
Outdated
private async fetch<T, L extends string>( | ||
definition: GaugeDefinition<T, L>, | ||
): Promise<MetricValue<L>[]> { | ||
const result = await definition.query(); | ||
if ( | ||
result !== undefined && | ||
result !== null && | ||
(!Array.isArray(result) || result.length > 0) | ||
) { | ||
const resultArray = this.asArray(definition.map(result)); | ||
resultArray | ||
.filter((r) => !Number.isInteger(r.value)) | ||
.forEach((r) => { | ||
this.log.warn( | ||
`Invalid value for ${definition.name}: ${r.value}. Value must be an integer.`, | ||
); | ||
}); | ||
return resultArray.filter((r) => Number.isInteger(r.value)); | ||
} | ||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encapsulate transformation from the query result (which can either be a single result or an array), into an array of valid metrics for prometheus
@@ -14,7 +14,7 @@ type MapResult<R, L extends string> = ( | |||
type GaugeDefinition<T, L extends string> = { | |||
name: string; | |||
help: string; | |||
labelNames: L[]; | |||
labelNames?: L[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support gauges without labels
03149bd
to
c458033
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Migrate some prometheus metrics to use the new and sequential metric updater