Currently, when MediaWiki processes a request, it takes care to propagate the `x-request-id` header from the incoming request to any requests to other services it makes "on behalf" of that request as part of handling it (for instance if MediaWiki fetches from Restbase, or Shellbox).
In order to implement distributed tracing, we'll also need to similarly propagate the `tracestate` and `traceparent` headers.
In the future we'll likely want to integrate MediaWiki with the OpenTelemetry client library, so we can add other context to traces within MediaWiki. But for now we can simply propagating these two headers without modifying them or even parsing them (as is allowed by the [[ https://www.w3.org/TR/trace-context/#design-overview | W3C TraceContext Recommendation ]])
== Implementation Note ==
Header propagation is done by the HeaderCallback class which uses PHP's [[https://www.php.net/manual/de/function.header-register-callback.php|register_header_callback]] mechanism. It's one of the rare cases where relying on global state is the right chice, since this integrates directly with the PHP runtime and matches PHP's per-request execution model.
This however makes it tricky to all the set of headers to propagate to be configurable. HeaderCallback::register() is called early in Setup.php, before initialization is complete and configuration is available. We should check whether it would be ok to register the callback later, after configuration is loaded, so we can pass the list of headers to HeaderCallback::register().