Skip to content

refactor: Align metrics with OTEL semantic guidelines#635

Open
keelerm84 wants to merge 1 commit intov9from
mk/sdk-2145/otel-convention
Open

refactor: Align metrics with OTEL semantic guidelines#635
keelerm84 wants to merge 1 commit intov9from
mk/sdk-2145/otel-convention

Conversation

@keelerm84
Copy link
Copy Markdown
Member

@keelerm84 keelerm84 commented Apr 8, 2026

Note

Medium Risk
Renames/remaps exported metric names and attribute keys to OTEL semconv and changes request-duration recording to capture status/error details, which can break dashboards/alerts and alter metric cardinality/aggregation behavior.

Overview
Updates Relay’s exported OTEL metrics to match semantic conventions: request/connection metrics are renamed to http.server.*, event metrics are renamed/reshaped (including new sent/error/dropped/pending instruments), and metric units/descriptions are standardized.

Refactors request instrumentation to record duration-only (removing the separate request counter) and to attach semconv attributes like http.route, http.request.method, url.scheme, http.response.status_code, network.protocol.version, and error.type by capturing status codes via a ResponseWriter wrapper.

Adjusts exporter configuration to use an exponential histogram view for http.server.request.duration, and updates docs/tests/routes middleware wiring accordingly.

Reviewed by Cursor Bugbot for commit d1cda13. Bugbot is set up for automated code reviews on this repo. Configure here.

@keelerm84 keelerm84 requested a review from a team as a code owner April 8, 2026 21:12
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d1cda13. Configure here.

} else {
protocolVersion = fmt.Sprintf("%d", req.ProtoMajor)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Protocol version incorrect for HTTP/1.0 requests

Low Severity

The protocolVersion logic uses req.ProtoMinor > 0 to decide whether to include the minor version. This produces "1" for HTTP/1.0 (ProtoMajor=1, ProtoMinor=0), but the OTEL network.protocol.version semantic convention expects "1.0". The logic works correctly for HTTP/1.1 → "1.1", HTTP/2 → "2", and HTTP/3 → "3", but mishandles the HTTP/1.0 case since the condition conflates "minor version is zero" with "minor version is irrelevant."

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d1cda13. Configure here.

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.

1 participant