codex-otel: add configurable trace metadata#21556
Conversation
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.
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Malformed span attribute keys and tracestate fields are user-editable config. Provider initialization installs process-global OTEL state, so sanitize that metadata during config loading. Bad entries now produce startup warnings instead of making startup fail, while valid sibling metadata is preserved. Project-local config comes from repository contents, so deny OTEL settings there to prevent repositories from controlling telemetry destinations or trace metadata.
|
One small cleanup request: can we reuse the new That keeps the config sanitization path and the provider defense-in-depth path using the same validation logic, so we don’t end up with two sources of truth if span attribute validation grows later. |
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.