fix: align OTel server span status with HTTP semantic conventions#1672
Merged
Conversation
8682ef1 to
3086e2a
Compare
ernado
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1671
Summary
Fixes OTel server span status handling in generated response encoders to follow the HTTP semantic conventions.
Generated server code now:
UnsetUnsetcodes.Erroronly for 5xx responsesThis is a follow-up to #1477. That PR fixed part of the server span error condition, but the generated response encoder still marked 4xx responses as
Errorand successful responses asOk.Motivation
For server spans, 4xx responses are client-side errors and should not be reported as server span errors. Also, OTel instrumentation should not set span status to
Okfor successful HTTP responses unless explicitly configured to do so.Reference:
https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
Changes
gen/_template/response_encode.tmplto set span status only for 5xx responses.Out of scope
Response encoding or response write failures after a non-5xx status has already been written are a related but separate issue and are not addressed by this PR.