fix(llmobs): make span data JSON-safe at span finish [backport 4.14] - #19813
Open
dd-octo-sts[bot] wants to merge 1 commit into
Open
fix(llmobs): make span data JSON-safe at span finish [backport 4.14]#19813dd-octo-sts[bot] wants to merge 1 commit into
dd-octo-sts[bot] wants to merge 1 commit into
Conversation
## Description Some integrations pass raw SDK request/config objects straight into the `metadata`/`config` dicts handed to `_annotate_llmobs_span_data()` — for example, the Google GenAI integration puts `SafetySetting` objects from the request config into span metadata. Those values ride along on the APM span's `_llmobs` meta_struct, which gets JSON-encoded by the agentless APM exporter later. That encoder has no fallback for non-JSON-serializable objects, so a `TypeError` there causes the **entire trace payload to be silently dropped** — not just the offending span. Observed in production as: ``` TypeError: Object of type SafetySetting is not JSON serializable when serializing list item 0 when serializing dict item 'safety_settings' when serializing dict item 'metadata' when serializing dict item 'meta' when serializing dict item '_llmobs' when serializing dict item 'meta_struct' when serializing list item N when serializing dict item 'spans' ``` This has shown up per-integration so far (Google GenAI's `safety_settings`, LangGraph's `tool_config` in #19711). Rather than chase it integration-by-integration — or field-by-field — this enforces JSON-safety once, **at span finish**. Claude session: `e0d1ad2b-5a78-4d3f-a480-4179abc30060` Resume: `claude --resume e0d1ad2b-5a78-4d3f-a480-4179abc30060` Co-authored-by: yun.kim <yun.kim@datadoghq.com> (cherry picked from commit b16f02e) Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
dd-octo-sts
Bot
requested review from
Kyle-Verhoog
and removed request for
a team
August 21, 2026 21:22
Codeowners resolved asResolved from the full PR diff against |
Circular import analysis
|
Dependency direction analysis
|
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport #19758 to 4.14