fix: gate OTel span content recording behind opt-in flag#2486
Open
amabito wants to merge 7 commits intoag2ai:mainfrom
Open
fix: gate OTel span content recording behind opt-in flag#2486amabito wants to merge 7 commits intoag2ai:mainfrom
amabito wants to merge 7 commits intoag2ai:mainfrom
Conversation
3077af3 to
61f3de0
Compare
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.
61f3de0 to
09caf6a
Compare
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 Report❌ Patch coverage is
... and 23 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_contentconfiguration 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