Skip to content

chore: Add http_route label to HTTP server metrics#2330

Merged
jnschaeffer merged 5 commits intomasterfrom
chore/metric-tags
Jan 28, 2026
Merged

chore: Add http_route label to HTTP server metrics#2330
jnschaeffer merged 5 commits intomasterfrom
chore/metric-tags

Conversation

@jnschaeffer
Copy link
Contributor

What kind of change does this PR introduce?

This PR adds the http_route label to standard HTTP server metrics collected by the otelhttp package. This enables users to collect HTTP metrics per route.

Because WithMetricAttributesFn is only available in newer versions of otelhttp, this commit also upgrades the otelhttp package to v0.63.0. As a result, HTTP request metrics now use the newer http_server_request_ naming convention rather than just http_server_.

What is the current behavior?

Currently, the http_server_duration_milliseconds_bucket metric does not include HTTP route labels. This means HTTP duration metrics are heavily skewed towards fast, frequently accessed API routes such as /user.

What is the new behavior?

There are two changes introduced in this PR:

  • The http_server_duration_milliseconds_bucket metric is renamed to http_server_request_duration_seconds_bucket
  • The http_server_request_duration_seconds_bucket metric has an additional label, http_route, that matches the http_route label in the http_status_codes_total metric

@jnschaeffer jnschaeffer requested a review from a team as a code owner January 15, 2026 03:14
@coveralls
Copy link

coveralls commented Jan 15, 2026

Pull Request Test Coverage Report for Build 21439568499

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 26 of 28 (92.86%) changed or added relevant lines in 1 file are covered.
  • 246 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.02%) to 68.848%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/observability/request-tracing.go 26 28 92.86%
Files with Coverage Reduction New Missed Lines %
internal/api/api.go 1 86.14%
internal/conf/configuration.go 4 99.34%
internal/models/refresh_token.go 6 70.25%
internal/tokens/service.go 73 80.11%
internal/api/mail.go 162 66.26%
Totals Coverage Status
Change from base Build 21238989279: 0.02%
Covered Lines: 14896
Relevant Lines: 21636

💛 - Coveralls

@jnschaeffer jnschaeffer force-pushed the chore/metric-tags branch 2 times, most recently from 26c6751 to b810990 Compare January 22, 2026 14:30
This commit adds the http_route label to HTTP server metrics, such as
`http_server_request_duration_seconds_bucket`. This enables users to
collect standard HTTP metrics per route rather than across all of
Auth.

Because `WithMetricAttributesFn` is only available in newer versions
of otelhttp, this commit also upgrades the otelhttp package to
v0.64.0. As a result, HTTP request metrics now use the newer
`http_server_request_` naming convention rather than just
`http_server_`.
This commit updates the semconv package to v1.38.0.
@jnschaeffer jnschaeffer merged commit 0e384b8 into master Jan 28, 2026
5 of 6 checks passed
@jnschaeffer jnschaeffer deleted the chore/metric-tags branch January 28, 2026 13:40
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.

3 participants