Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion 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: Optional[bool] = None,
) -> Optional[Client]:
"""Initialize Traceloop tracing, metrics, and instrumentation.

Expand All @@ -88,6 +89,10 @@ 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 trace prompt/completion content. If not set,
uses the ``TRACELOOP_TRACE_CONTENT`` environment variable
(defaults to ``True``). Set to ``False`` to disable sending
sensitive content in traces.
"""
if use_attributes is not None and use_legacy_attributes is not None:
raise TypeError(
Expand Down Expand Up @@ -125,7 +130,7 @@ def init(
print(Fore.YELLOW + "Tracing is disabled" + Fore.RESET)
return

enable_content_tracing = is_content_tracing_enabled()
enable_content_tracing = is_content_tracing_enabled(trace_content)

if exporter and processor:
warnings.warn(
Expand Down
5 changes: 4 additions & 1 deletion packages/traceloop-sdk/traceloop/sdk/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import os
from typing import Optional


def is_tracing_enabled() -> bool:
return (os.getenv("TRACELOOP_TRACING_ENABLED") or "true").lower() == "true"


def is_content_tracing_enabled() -> bool:
def is_content_tracing_enabled(trace_content: Optional[bool] = None) -> bool:
if trace_content is not None:
return trace_content
return (os.getenv("TRACELOOP_TRACE_CONTENT") or "true").lower() == "true"


Expand Down