Skip to content

Fix DD_APM_TRACING_ENABLED to work with LLMObs#10989

Open
matsumo-and wants to merge 4 commits intoDataDog:masterfrom
matsumo-and:fix/LLMOBS-10051
Open

Fix DD_APM_TRACING_ENABLED to work with LLMObs#10989
matsumo-and wants to merge 4 commits intoDataDog:masterfrom
matsumo-and:fix/LLMOBS-10051

Conversation

@matsumo-and
Copy link
Copy Markdown

@matsumo-and matsumo-and commented Mar 28, 2026

What Does This Do

This PR fixes two issues when using LLM Observability without APM tracing:

  1. Makes DD_APM_TRACING_ENABLED=false properly drop APM traces while keeping LLMObs traces
  2. Prevents NullPointerException when DD_TRACE_ENABLED=false is set with LLMObs enabled

Motivation

Solves #10051

Currently, when DD_APM_TRACING_ENABLED=false is set with DD_LLMOBS_ENABLED=true, APM traces are still sent to the agent because the sampler selection logic falls through to the default sampler, which keeps all traces by default.

Additionally, setting DD_TRACE_ENABLED=false causes NPE in LLMObs methods because LLMObs tries to initialize even when all tracing is disabled.

Additional Notes

Implementation approach:

  1. ProductTraceSource.LLMOBS flag (0x20): Added following the existing pattern for ASM/DSM/DBM products
  2. LlmObsStandaloneSampler: New sampler that drops all traces by default (SAMPLER_DROP) but keeps traces with the LLMOBS marker (SAMPLER_KEEP)
  3. DDLLMObsSpan marking: Uses TraceSegment.setTagTop() to propagate the LLMOBS flag from child spans to the root span, following the exact same pattern used by ASM (AppSecEventTracker, GatewayBridge, IAST Reporter)
  4. Sampler selection logic: Updated to choose LlmObsStandaloneSampler when DD_APM_TRACING_ENABLED=false and DD_LLMOBS_ENABLED=true
  5. NPE prevention: Added early return in LLMObsSystem.start() when !config.isTraceEnabled()

Testing:

  • Added smoke tests in dd-smoke-tests/apm-tracing-disabled/
  • Verified on master: LLMObs works but APM traces not dropped
  • Verified on fix branch: LLMObs works and APM traces properly dropped

Contributor Checklist

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

Signed-off-by: matsumo-and <yh134.toisanda@gmail.com>
Fixes DataDog#10051

When DD_APM_TRACING_ENABLED=false is set, APM tracing should be disabled
while allowing other products like LLM Observability to function. Previously,
setting DD_APM_TRACING_ENABLED=false would inadvertently disable LLMObs or
allow APM traces to leak through when no other products were enabled.

Signed-off-by: matsumo-and <yh134.toisanda@gmail.com>
Signed-off-by: matsumo-and <yh134.toisanda@gmail.com>
@matsumo-and matsumo-and marked this pull request as ready for review March 28, 2026 10:13
@matsumo-and matsumo-and requested review from a team as code owners March 28, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant