Skip to content

fix(llmobs): mark APM spans when SDK submits LLMObs event to prevent processor duplication#17212

Draft
ZStriker19 wants to merge 2 commits intomainfrom
zach.groves/mlos-523/llmobs-dedup
Draft

fix(llmobs): mark APM spans when SDK submits LLMObs event to prevent processor duplication#17212
ZStriker19 wants to merge 2 commits intomainfrom
zach.groves/mlos-523/llmobs-dedup

Conversation

@ZStriker19
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #17007 (MLOS-523). Fixes duplicate LLMObs events for customers using both the ddtrace SDK and Strands OTel gen_ai instrumentation.

Root cause: When the SDK submits LLMObs events for OTel gen_ai spans (via the OTel bridge), the dd-go backend processor independently creates another LLMObs event for the same span (because it has gen_ai.* attributes). This produces two LLMObs events with the same span ID.

Fix: Tag the APM span with _dd.llmobs.submitted=1 when the SDK enqueues an LLMObs event for it. The companion dd-go PR reads this tag in isRelevantForLLMObs and skips the span, preventing the duplicate.

This only affects spans the SDK explicitly handles. Spans that are purely OTel (not submitted by the SDK writer) are unaffected and continue to be created by the processor as before.

Companion PR

dd-go: DataDog/dd-go (link TBD — branch: zach.groves/mlos-523/llmobs-dedup)

Test plan

  • test_llmobs_submitted_tag_set_on_apm_span — SDK span gets marker
  • test_llmobs_submitted_tag_not_set_without_llmobs — non-SDK span does not get marker
  • End-to-end: trace with both SDK and OTel gen_ai spans shows each span exactly once

🤖 Generated with Claude Code

ZStriker19 and others added 2 commits March 31, 2026 09:37
…processor duplication

When the ddtrace SDK submits an LLMObs event for a span (including OTel
gen_ai spans handled via the OTel bridge), tag the APM span with
_dd.llmobs.submitted=1. The dd-go backend processor reads this tag and
skips the span, preventing duplicate LLMObs events when both the SDK and
the processor would otherwise cover the same span.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

releasenotes/notes/llmobs-dedup-sdk-submitted-26dd929582d8d617.yaml     @DataDog/apm-python

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