riandyrn / otelchi

OpenTelemetry instrumentation for go-chi/chi
Apache License 2.0
114 stars 35 forks source link

Feat/add trace id in response header #36

Closed ProtozoaJr closed 5 months ago

ProtozoaJr commented 5 months ago

This pull request addresses the behavior mentioned in the comment at here and here regarding adding the trace ID to the response header. By default, the code adds the X-Trace-ID header to the response, which might not be desirable for all users, especially when the WithTraceResponseHeaderKey option is not used.

To align with user expectations and improve flexibility, this PR modifies the code to only add the trace ID to the response header when the WithTraceResponseHeaderKey option is explicitly used. This change ensures that the response header is modified only when required, providing better control over the tracing behavior.

Changes:

This change enhances the usability and flexibility of the tracing middleware, allowing users to customize the tracing behavior more precisely based on their requirements.

Related Issue(s): Trace ID in header