opentelemetry-js icon indicating copy to clipboard operation
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

Open googol opened this issue 3 years ago • 4 comments

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)

googol avatar Sep 08 '22 20:09 googol

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.

github-actions[bot] avatar Nov 14 '22 06:11 github-actions[bot]

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.

legendecas avatar Nov 14 '22 08:11 legendecas

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

googol avatar Nov 14 '22 11:11 googol

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

legendecas avatar Nov 18 '22 07:11 legendecas

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.

github-actions[bot] avatar Jan 23 '23 06:01 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Feb 13 '23 06:02 github-actions[bot]