Conversation
The openai-java decorators read the response token counts but tagged them behind the LLM Observability guard, so APM spans carried no usage when LLM Observability was off. Route each count through TokenUsage, which keeps the _ml_obs_metric.* tags when LLM Observability is enabled and writes the matching gen_ai.usage.* metric when it is not. Matches dd-trace-js. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Stacked on #12450.
What Does This Do
The openai-java decorators already read the token counts off each response, but tagged them behind the
llmObsEnabledguard, so an APM span carriedgen_ai.operation.name,gen_ai.request.model,gen_ai.provider.nameandgen_ai.application.namebut no usage when LLM Observability was off.Each count now goes through
TokenUsage.set, which keeps writing the_ml_obs_metric.*tag when LLM Observability is enabled (byte-identical to today) and writes the matchinggen_ai.usage.*APM metric when it is not. Covers all four endpoints: chat completions (streaming included, usage only, as dd-trace-js does), responses, embeddings and legacy completions.Motivation
Parity with dd-trace-js, which emits
gen_ai.usage.*fromsetGenAiApmUsageMetricson the LLM-Observability-disabled path.Additional Notes
_ml_obs_metric.*tags stay behind the guard, so APM spans of users who never enabled LLM Observability do not pick up LLM Observability internal tags.The shared mock OpenAI server in the forked tests now returns real chat-completion and embedding JSON with a
usageblock, so the token counts have something to come from.🤖 Generated with Claude Code