You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I upgraded fastify-metrics from 8.0.0 to 9.2.1. Changed plugin registration code to use new configuration options. Metrics are being collected and exposed under the route I want. However, I didn't found any way to add custom prefix to default metric names. prefix option available in 8.0.0 no longer works.
I am wondering if this is an expected behavior? And if so, what is the rationale behind this breaking change or maybe there are some workarounds?
With custom metrics everything is fine. I've included code and endpoint output in sections below.
After upgrade
Code:
app.register(require("fastify-metrics"),{prefix: 'app_',// this no longer works. I failed to find an equivalent for thisrouteBlacklist: [`/internal/metrics`,`/internal/health/readiness`]})
Endpoint output:
# HELP nodejs_version_info Node.js version info.
# TYPE nodejs_version_info gauge
nodejs_version_info{version="v16.15.0",major="16",minor="15",patch="0"} 1
# HELP nodejs_version_info Node.js version info.
# TYPE nodejs_version_info gauge
app_nodejs_version_info{version="v16.15.0",major="16",minor="15",patch="0"} 1
The text was updated successfully, but these errors were encountered:
After looking into sources of both fastify-metrics and prom-client I figured out how to configure what I want. Posting it here in case someone will face the same problems as me during upgrade.
app.register(require("fastify-metrics"),{defaultMetrics: {enabled: true,// this is the default value and can be omittedprefix: 'app_'},routeMetrics: {enabled: true,// this is the default value and can be omittedrouteBlacklist: [`/internal/metrics`,`/internal/health/readiness`],overrides: {histogram: {name: `app_http_request_duration_seconds`},summary: {name: `app_http_request_summary_seconds`}},}})
Essentially, all options under defaultMetrics key are being passed to prom-client, including prefix.
To add prefix to request histogram and summary, one should use overrides key and provide a prefixed name. v9 does not use prefix passed for default metrics for request histogram and summary.
Hello,
I upgraded
fastify-metrics
from8.0.0
to9.2.1
. Changed plugin registration code to use new configuration options. Metrics are being collected and exposed under the route I want. However, I didn't found any way to add custom prefix to default metric names.prefix
option available in8.0.0
no longer works.I am wondering if this is an expected behavior? And if so, what is the rationale behind this breaking change or maybe there are some workarounds?
With custom metrics everything is fine. I've included code and endpoint output in sections below.
After upgrade
Code:
Endpoint output:
Before upgrade
Code:
Endpoint output:
The text was updated successfully, but these errors were encountered: