refactor: Align metrics with OTEL semantic guidelines#635
refactor: Align metrics with OTEL semantic guidelines#635
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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) | ||
| } | ||
| } |
There was a problem hiding this comment.
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."
Reviewed by Cursor Bugbot for commit d1cda13. Configure here.


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, anderror.typeby capturing status codes via aResponseWriterwrapper.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.