Skip to content

fix: remove setStatus(OK) calls to comply with OTel spec#135

Merged
metcoder95 merged 1 commit intofastify:mainfrom
newbee1939:fix/finalize-span-hooks-status
Mar 4, 2026
Merged

fix: remove setStatus(OK) calls to comply with OTel spec#135
metcoder95 merged 1 commit intofastify:mainfrom
newbee1939:fix/finalize-span-hooks-status

Conversation

@newbee1939
Copy link
Contributor

Fixes #126

Remove setStatus(OK) calls from finalizeResponseSpanHook and finalizeNotFoundSpanHook to comply with the OTel spec, which states instrumentation libraries should leave span status as Unset unless there is an error.

  • Only set SpanStatusCode.ERROR for 5xx responses
  • Use reply.statusCode instead of hardcoded 404 in finalizeNotFoundSpanHook

Checklist

Signed-off-by: h6o <48004352+newbee1939@users.noreply.github.com>
@newbee1939 newbee1939 marked this pull request as ready for review March 3, 2026 23:23
@metcoder95 metcoder95 merged commit 9ff035c into fastify:main Mar 4, 2026
17 checks passed
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.

finalizeResponseSpanHook and finalizeNotFoundSpanHook set OK status on non-5xx responses, violating OTel spec

2 participants