feat(traceloop-sdk): add trace_content parameter to Traceloop.init()#4367
feat(traceloop-sdk): add trace_content parameter to Traceloop.init()#4367smz202000 wants to merge 1 commit into
Conversation
Add a parameter to that allows users to control whether sensitive content (prompts and completions) is sent in traces. When the parameter is not set (None), the existing environment variable is used (backward compatible). When explicitly set to True or False, it overrides the environment variable. This addresses the feature request in issue traceloop#137, giving users more granular control over content tracing directly from the API without relying solely on environment variables. Changes: - Modified in config to accept an optional parameter that overrides the env var - Added parameter to - Added docstring documentation for the new parameter
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesTrace content configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Independent privacy review against I ran the same matrix against
Minimal regression check: monkeypatch.setenv("TRACELOOP_TRACE_CONTENT", "true")
Traceloop.init(
exporter=InMemorySpanExporter(),
disable_batch=True,
trace_content=False,
)
assert TracerWrapper.enable_content_tracing is False
assert should_send_prompts() is False # currently TrueI also exercised an OpenAI chat span with an in-memory exporter and a mock HTTP transport (no provider call). With The existing SDK privacy tests pass (29/29) because they disable content through the environment variable and therefore do not cover this split-brain case. I think this needs an end-to-end regression test at the instrumentation/span boundary before merge; changing only |
Summary
Adds a
trace_contentparameter toTraceloop.init()that allows users to control whether sensitive content (prompts and completions) is sent in traces.Fixes #137
Changes
is_content_tracing_enabled()intraceloop/sdk/config/__init__.pyto accept an optionaltrace_contentparameter. When explicitly provided, it overrides theTRACELOOP_TRACE_CONTENTenvironment variable. When not provided (None), it falls back to the environment variable (backward compatible).trace_content: Optional[bool] = Noneparameter toTraceloop.init()intraceloop/sdk/__init__.py.Usage
Backward Compatibility
This change is fully backward compatible. When
trace_contentis not passed (the default), the existingTRACELOOP_TRACE_CONTENTenvironment variable behavior is preserved.Summary by CodeRabbit