Skip to content

Add in LLM Observability Span Processor API - #12112

Draft
sabrenner wants to merge 4 commits into
masterfrom
sabrenner/llmobs-span-processor
Draft

Add in LLM Observability Span Processor API#12112
sabrenner wants to merge 4 commits into
masterfrom
sabrenner/llmobs-span-processor

Conversation

@sabrenner

@sabrenner sabrenner commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Adds in a user span processor API to process LLM Observability / Agent Observability spans before they are flushed to Datadog.

Motivation

Being able to redact input / output on certain spans, by analyzing tags on the LLM Observability span.

Additional Notes

Contributor Checklist

Jira ticket: MLOB-7902

@sabrenner sabrenner added type: feature Enhancements and improvements comp: mlobs ML Observability (LLMObs) labels Jul 30, 2026
@sabrenner

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 9f02ef6973

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dd-octo-sts

dd-octo-sts Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.01 s 13.95 s [-0.5%; +1.4%] (no difference)
startup:insecure-bank:tracing:Agent 12.89 s 13.04 s [-1.9%; -0.4%] (maybe better)
startup:petclinic:appsec:Agent 16.90 s 16.74 s [-0.0%; +1.9%] (no difference)
startup:petclinic:iast:Agent 16.96 s 16.96 s [-1.0%; +1.1%] (no difference)
startup:petclinic:profiling:Agent 16.67 s 16.85 s [-2.1%; +0.0%] (no difference)
startup:petclinic:sca:Agent 16.18 s 16.60 s [-6.7%; +1.7%] (no difference)
startup:petclinic:tracing:Agent 16.16 s 16.17 s [-1.0%; +0.9%] (no difference)

Commit: 113074bd · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 30, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 63.91%
Overall Coverage: 57.35% (-0.43%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 113074b | Docs | Datadog PR Page | Give us feedback!

@sabrenner sabrenner left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self-review

Comment on lines +17 to +20
private static final String LLMOBS_TAG_PREFIX = "_ml_obs_tag.";
private static final String INPUT_TAG = LLMOBS_TAG_PREFIX + "input";
private static final String OUTPUT_TAG = LLMOBS_TAG_PREFIX + "output";
private static final String SPAN_KIND_TAG = LLMOBS_TAG_PREFIX + Tags.SPAN_KIND;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use constants from other files? or are they not defined anywhere?

List<LLMObs.LLMMessage> messages = new ArrayList<>(values.size());
for (Object value : values) {
if (!(value instanceof LLMObs.LLMMessage)) {
throw new IllegalArgumentException(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this check? don't we always call this function with a list of LLMObs.LLMMessage objects?

List<? extends CoreSpan<?>> llmobsSpans =
trace.stream().filter(LLMObsSpanMapper::isLLMObsSpan).collect(Collectors.toList());

boolean retry = trace == pendingTrace;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems this logic was added to avoid retry issues with mapping. however, since this is currently possible in master, why do we need to add new handling? we might be introducing unnecessary overhead on extra checks and objects when not needed

// 3
writable.writeUTF8(PARENT_ID);
writable.writeString(span.getTag(PARENT_ID_TAG_INTERNAL_FULL), null);
span.removeTag(PARENT_ID_TAG_INTERNAL_FULL);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could be misreading the diff, but it looks like this tag is no longer removed in the new code?

LLMOBS_TAG_PREFIX + LLMObsTags.SESSION_ID;

private final MetaWriter metaWriter = new MetaWriter();
private final Set<CoreSpan<?>> droppedSpans = Collections.newSetFromMap(new IdentityHashMap<>());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be an instance variable? or can we keep it scoped to the map function?

} else {
++tagsSize;
}
} else if (key.startsWith(LLMOBS_TAG_PREFIX) && !key.equals(PARENT_ID_TAG_INTERNAL_FULL)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the logic changed here necessary? seems we don't need to have this changed for the task at hand

String key = tag.getKey();
Object value = tag.getValue();
if (!tagsToRemapToMeta.containsKey(key) && key.startsWith(LLMOBS_TAG_PREFIX)) {
if (!tagsToRemapToMeta.containsKey(key)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise this seems like a non-scoped change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: mlobs ML Observability (LLMObs) type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant