This commit is contained in:
Alex Garcia 2026-10-13 00:40:29 -04:00 • committed by GitHub
commit 9cb8e37ad8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 180 additions and 1 deletions

View file

@ -4,6 +4,13 @@
Changelog
=========
.. _unreleased:
Unreleased
----------
- Responses now include the request span's trace context in ``traceresponse`` and ``Server-Timing`` headers while tracing is recording. See :ref:`internals_telemetry_response_headers`. (:issue:`1730`)
.. _v1_0_a41:
1.0a41 (2026-09-24)

View file

@ -2644,6 +2644,20 @@ A request to a table page produces a span named, in full::
.. [[[end]]]
.. _internals_telemetry_response_headers:
Trace context in responses
~~~~~~~~~~~~~~~~~~~~~~~~~~
While the request span is recording, every response includes that span's trace context in two headers::
traceresponse: 00-<trace-id>-<span-id>-<flags>
Server-Timing: traceparent;desc="00-<trace-id>-<span-id>-<flags>"
``traceresponse`` is the W3C Trace Context Level 2 response header. If CORS is enabled, ``traceresponse`` is added to the existing ``Access-Control-Expose-Headers`` value so cross-origin ``fetch()`` calls can read it. ``Server-Timing`` lets page JavaScript read the trace context through ``performance.getEntriesByType("navigation")[0].serverTiming``. Datasette does not set ``Timing-Allow-Origin``.
Neither header is sent if no tracer provider is installed. If the sampler dropped the trace, the flags are ``00`` and the IDs will not be found in your tracing backend.
.. _internals_telemetry_metrics:
Metric reference