Skip to content

fix(ext/otel): don't mark server spans as error for 4xx responses#32722

Merged
bartlomieju merged 1 commit intomainfrom
fix/otel-server-span-status
Mar 15, 2026
Merged

fix(ext/otel): don't mark server spans as error for 4xx responses#32722
bartlomieju merged 1 commit intomainfrom
fix/otel-server-span-status

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

  • Per OTel HTTP semantic conventions, server spans should only have ERROR status for 5xx responses. 4xx responses are client errors — the server handled the request correctly.
  • Previously, updateSpanFromResponse treated all >= 400 responses as errors regardless of span kind, causing 404s to show as faults/errors in tracing backends (AWS X-Ray, Grafana Tempo, etc.).
  • Split into updateSpanFromClientResponse (errors on >= 400) and updateSpanFromServerResponse (errors on >= 500) with a shared setResponseAttributes helper.

Fixes #29615

Test plan

  • Added http_server_status spec test covering 200, 404, and 500 responses with both client and server spans
  • Server 404 span: no error.type, status.code: 0 (UNSET)
  • Server 500 span: error.type: "500", status.code: 2 (ERROR)
  • Client 404 span: error.type: "404", status.code: 2 (ERROR) — unchanged
  • Existing otel_basic::fetch test passes (client-side behavior unchanged)

🤖 Generated with Claude Code

Per OTel HTTP semantic conventions, server spans should only have ERROR
status for 5xx responses. 4xx responses are client errors and should not
be marked as errors on the server side. Client spans correctly continue
to treat all >= 400 responses as errors.

Split `updateSpanFromResponse` into `updateSpanFromClientResponse` (errors
on >= 400) and `updateSpanFromServerResponse` (errors on >= 500).

Fixes #29615

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

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

Reviewed the changes with full repo context. No issues found.

@bartlomieju bartlomieju merged commit 622a15e into main Mar 15, 2026
112 checks passed
@bartlomieju bartlomieju deleted the fix/otel-server-span-status branch March 15, 2026 12:07
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.

Opentelemetry returning 404's as errors in the tracing

3 participants