opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Clear baggage received as part of http instrumentation.

Open darren-west opened this issue 1 year ago • 5 comments

I am using http auto instrumentation but I'm looking at a way to clear any baggage received as part of propagation. In my example I have an API and I want to not accept any baggage. How can I achieve this?

  • [x] This only affects the JavaScript OpenTelemetry library
  • [ ] This may affect other libraries, but I would like to get opinions here first

darren-west avatar Nov 02 '23 09:11 darren-west

Maybe don't register the W3CBaggagePropagator? But this is not limited to HTTP, would also effect GRPC,...

Flarna avatar Nov 02 '23 09:11 Flarna

Maybe don't register the W3CBaggagePropagator? But this is not limited to HTTP, would also effect GRPC,...

Thanks @Flarna

Do you know how this can be done? I cant see a way to update the baggage propagator in the NodeTraceProvider?

I actually want to block incoming baggage but push some baggage outbound so I dont want to completely disable the propagator but I could make the extract function a noop operation.

darren-west avatar Nov 02 '23 11:11 darren-west

You can manually specify the propagators you want during calling register. e.g.

const provider = new NodeTracerProvider();
provider.register({
  propagator: new W3CTraceContextPropagator()
});

It should also work to set environment variable to e.g. OTEL_PROPAGATORS=tracecontext. Default if not set is tracecontext,baggage.

Flarna avatar Nov 02 '23 12:11 Flarna

I actually want to block incoming baggage but push some baggage outbound so I dont want to completely disable the propagator but I could make the extract function a noop operation.

I guess in this case you need a custom propagator which you easily can create from the existing baggage propagator.

But I wonder why you want to send out something which never gets read from anyone.

Flarna avatar Nov 02 '23 12:11 Flarna

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 22 '24 06:01 github-actions[bot]

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

github-actions[bot] avatar Mar 11 '24 06:03 github-actions[bot]