opentelemetry-js
opentelemetry-js copied to clipboard
(instrumentation-http) Add callback for deciding whether to use incoming propagation headers as trace parent, linked span or to discard
Is your feature request related to a problem? Please describe.
I'm running an api that accepts http requests from other systems. Sometimes those calls include trace propagation headers. If those calls are coming in from outside systems, at best this causes my observability ui to show missing traces, but if they include the "not sampled" flag, it will actually affect my own traces, depending on configuration causing my traces to not get sampled. It might however be useful to keep some reference to the incoming trace propagation headers as links, since that might help debug calls with partners. Also this same api might be called from other systems I control, in which case I'd like the traces to be connected.
Describe the solution you'd like
I would like to have a callback in the configuration object of the HttpInstrumentation constructor that would receive the incoming request object and decide if the trace parent from the propagation headers should be used as the parent trace, simply linked to the http handler span (which would be the root), or discared completely.
Describe alternatives you've considered
My current workaround is to use my nginx-ingress to completely drop the trace propagation headers, but that won't work when I have internal systems calling my service as well (or I'll have to get more comfortable with nginx configuration)
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
I don't think this fits in the scope of the instrumentation. You can define your own propagator to discard unexpected trace flags from propagating. Check out this doc for more details: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/propagation.md.
Is that even possible? As far as I know, only the http headers are available to the propagator, and not any other properties of the incoming http request
What else properties do you need to access in order to decide if tracing is needed? You can also insert your own code in the HTTP instrumentation with the documented hooks: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http#http-instrumentation-options
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.