Skip to content

fix: gate OTel span content recording behind opt-in flag#2486

Open
amabito wants to merge 7 commits intoag2ai:mainfrom
amabito:fix/otel-content-gating
Open

fix: gate OTel span content recording behind opt-in flag#2486
amabito wants to merge 7 commits intoag2ai:mainfrom
amabito:fix/otel-content-gating

Conversation

@amabito
Copy link
Copy Markdown
Contributor

@amabito amabito commented Mar 16, 2026

Why are these changes needed?

OTel instrumentators unconditionally record full message content, tool arguments, and LLM responses into span attributes. In production deployments where traces are exported to third-party observability backends, this leaks PII, API keys, and proprietary prompts.

The fix adds a record_content configuration flag (default False) that gates content recording. When disabled, spans still capture structural metadata (tool names, token counts, model IDs) without exposing sensitive content.

Related issue number

Addresses a content leakage vulnerability reported via email to @Lancetnik on 2026-03-16.

Checks

@amabito amabito force-pushed the fix/otel-content-gating branch 2 times, most recently from 3077af3 to 61f3de0 Compare March 16, 2026 23:05
Existing tests verify that content is attached to spans, so they need
record_content=True. Add autouse fixture in conftest that sets the flag
for the test suite while production default remains OFF.
@amabito amabito force-pushed the fix/otel-content-gating branch from 61f3de0 to 09caf6a Compare March 16, 2026 23:17
amabito added 5 commits March 17, 2026 08:34
Cover the RECORD_CONTENT=False code paths across all four
instrumentators (chat, reply, tool, human_input) to satisfy
the codecov patch coverage requirement. Tests verify that
content-bearing span attributes are absent while structural
metadata remains present.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...etry/instrumentators/agent_instrumentators/chat.py 73.33% 0 Missing and 4 partials ⚠️
Files with missing lines Coverage Δ
...y/instrumentators/agent_instrumentators/_config.py 100.00% <100.00%> (ø)
...strumentators/agent_instrumentators/human_input.py 100.00% <100.00%> (ø)
...try/instrumentators/agent_instrumentators/reply.py 89.02% <100.00%> (+5.07%) ⬆️
...etry/instrumentators/agent_instrumentators/tool.py 100.00% <100.00%> (ø)
...etry/instrumentators/agent_instrumentators/chat.py 83.24% <73.33%> (+1.33%) ⬆️

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant