Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/traceloop-sdk/traceloop/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def init(
endpoint_is_traceloop: Optional[bool] = False,
use_attributes: Optional[bool] = None,
use_legacy_attributes: Optional[bool] = None,
trace_content: bool = True,
) -> Optional[Client]:
"""Initialize Traceloop tracing, metrics, and instrumentation.

Expand All @@ -88,6 +89,11 @@ def init(
events have nowhere to go and no prompt/completion data will be recorded.
use_legacy_attributes: Deprecated alias for ``use_attributes``. Will be
removed in a future release.
trace_content: Whether to send sensitive content (prompts,
completions) to the tracing backend. Defaults to ``True``.
When set to ``False``, overrides the ``TRACELOOP_TRACE_CONTENT``
environment variable and disables content capture across all
instrumentations.
"""
if use_attributes is not None and use_legacy_attributes is not None:
raise TypeError(
Expand Down Expand Up @@ -117,6 +123,9 @@ def init(
)
return

if not trace_content:
os.environ["TRACELOOP_TRACE_CONTENT"] = "false"

Comment on lines +126 to +128

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Make trace_content=False take precedence over context opt-ins.

This only sets the environment variable. packages/opentelemetry-instrumentation-anthropic/opentelemetry/instrumentation/anthropic/utils.py:30-34 still sends prompts when override_enable_content_tracing is set, even with TRACELOOP_TRACE_CONTENT=false. That violates the documented hard opt-out “across all instrumentations.” Ensure downstream gates cannot re-enable content when this SDK option disables it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/traceloop-sdk/traceloop/sdk/__init__.py` around lines 126 - 128,
Update the trace-content configuration around the __init__ initialization logic
so trace_content=False is enforced as a hard opt-out across downstream
instrumentations, including the override_enable_content_tracing gate in
Anthropic instrumentation. Ensure context-level opt-ins cannot re-enable
prompt/content capture when TRACELOOP_TRACE_CONTENT is false, while preserving
existing opt-in behavior when trace_content is enabled.

api_endpoint = os.getenv("TRACELOOP_BASE_URL") or api_endpoint
api_key = os.getenv("TRACELOOP_API_KEY") or api_key
Traceloop.__app_name = app_name
Expand Down