mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
codex-otel: add configurable trace metadata (#21556)
Add Codex config for static trace span attributes and structured W3C tracestate field upserts. The config flows through OtelSettings so callers can attach trace metadata without touching every span call site. Apply span attributes with an SDK span processor so every exported trace span carries the configured metadata. Model tracestate as nested member fields so configured keys can be upserted while unrelated propagated state in the same member is preserved. Validate configured tracestate before installing provider-global state, including header-unsafe values the SDK does not reject by itself. This keeps Codex from propagating malformed trace context from config. Update the config schema, public docs, and OTLP loopback coverage for config parsing, span export, propagation, and invalid-header rejection.
This commit is contained in:
@@ -26,3 +26,24 @@ When enabled, Codex appends a `Co-authored-by:` trailer using the configured
|
||||
attribution value. If `commit_attribution` is omitted, Codex uses
|
||||
`Codex <noreply@openai.com>`. Set `commit_attribution = ""` to disable the
|
||||
trailer while leaving the feature flag enabled.
|
||||
|
||||
## OpenTelemetry Trace Metadata
|
||||
|
||||
Codex can add static OpenTelemetry span attributes to exported trace spans and
|
||||
static W3C tracestate fields to propagated trace context:
|
||||
|
||||
```toml
|
||||
[otel.span_attributes]
|
||||
"example.trace_attr" = "enabled"
|
||||
|
||||
[otel.tracestate.example]
|
||||
alpha = "one"
|
||||
beta = "two"
|
||||
```
|
||||
|
||||
Nested `otel.tracestate` tables are encoded as semicolon-separated `key:value`
|
||||
fields inside the named tracestate member. If propagated trace context already
|
||||
has the named member, Codex upserts configured fields and preserves other fields
|
||||
in that member. This config shape does not support setting opaque tracestate
|
||||
member values. Invalid trace metadata entries are ignored during config load and
|
||||
reported as startup warnings.
|
||||
|
||||
Reference in New Issue
Block a user