openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

🐛 Bug Report: OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT is ignored, only TRACELOOP_TRACE_CONTENT disables content capture

Open doronkopit5 opened this issue 4 weeks ago • 1 comments

Which component is this bug for?

All instrumentations

📜 Description

Content capture (prompts and completions) can only be turned off with the Traceloop-specific TRACELOOP_TRACE_CONTENT env var, which 24 instrumentation packages read with a default of "true" (for example openai/utils.py:202, anthropic/utils.py:32). The standard OTel GenAI variable OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT is ignored, so users following the OTel docs still send prompt and completion content, which may contain PII.

watsonx defines is_content_enabled() reading the OTel variable (watsonx/utils.py:45), but nothing calls it.

👟 Reproduction steps

  1. export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=false
  2. Run any instrumented LLM call (for example OpenAI chat) with a console exporter

👍 Expected behavior

No gen_ai.input.messages / gen_ai.output.messages on the span.

👎 Actual Behavior with Screenshots

Both attributes are present with the full prompt and completion. Only TRACELOOP_TRACE_CONTENT=false removes them.

🤖 Python Version

3.12

📃 Provide any additional context for the Bug.

Suggested fix: one shared helper (for example in opentelemetry-semantic-conventions-ai) that honors OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT and keeps TRACELOOP_TRACE_CONTENT as a fallback, used by every package instead of the per-package copies. The default (on vs off when neither is set) needs a decision: the OTel convention is off by default, today it is on.

doronkopit5 avatar Nov 04 '26 11:11 doronkopit5

Hi @doronkopit5 — I'm planning to take this on: introduce one shared helper in opentelemetry-semantic-conventions-ai that resolves content capture as

  1. OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT when explicitly set,
  2. otherwise TRACELOOP_TRACE_CONTENT (existing default true), plus the existing override_enable_content_tracing context value,

and migrate the per-package copies to it mechanically. I'll keep the "neither variable set" default unchanged and add tests that prove the OTel variable is currently ignored and respected after the fix.

Please let me know if you'd prefer different precedence (or a different default when neither variable is set) before I open the PR.

yuee3 avatar Nov 05 '26 04:11 yuee3