llama-stack-mirror/llama_stack
Ben Browning dd57eff47b feat: Propagate W3C trace context headers from clients
This extracts the W3C trace context headers (traceparent and
tracestate) from incoming requests, stuffs them as attributes on the
spans we create, and uses them within the tracing provider
implementation to actually wrap our spans in the proper context.

What this means in practice is that when a client (such as an OpenAI
client) is instrumented to create these traces, we'll continue that
distributed trace within Llama Stack as opposed to creating our own
root span that breaks the distributed trace between client and server.

It's slightly awkward to do this in Llama Stack because our Tracing
API knows nothing about opentelemetry, W3C trace headers, etc - that's
only knowledge the specific provider implementation has. So, that's
why the trace headers get extracted by in the server code but not
actually used until the provider implementation to form the proper
context.

This also centralizes how we were adding the `__root__` and
`__root_span__` attributes, as those two were being added in different
parts of the code instead of from a single place.

Fixes #2097

Signed-off-by: Ben Browning <bbrownin@redhat.com>
2025-05-13 08:36:58 -04:00
..
apis feat: add metrics query API (#1394) 2025-05-07 10:11:26 -07:00
cli chore(refact)!: simplify config management (#1105) 2025-05-07 09:18:12 -07:00
distribution feat: Propagate W3C trace context headers from clients 2025-05-13 08:36:58 -04:00
models fix: llama4 tool use prompt fix (#2103) 2025-05-06 22:18:31 -07:00
providers feat: Propagate W3C trace context headers from clients 2025-05-13 08:36:58 -04:00
strong_typing chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
templates fix: revert "feat(provider): adding llama4 support in together inference provider (#2123)" (#2124) 2025-05-08 15:18:16 -07:00
__init__.py export LibraryClient 2024-12-13 12:08:00 -08:00
env.py refactor(test): move tools, evals, datasetio, scoring and post training tests (#1401) 2025-03-04 14:53:47 -08:00
log.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
schema_utils.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00