-
Notifications
You must be signed in to change notification settings - Fork 324
Add openai-java v3.0+ instrumentation #9959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…stead of forcing it
…d "streamed async request completion test with withRawResponse"
Call decorateWithResponse from the wrappers
Rename span resources to be aligned with trace-py Add http.client resource assertion
Test case renaming
Reorder tests by synch, async
Fix Embeddings fixture for the latestDepTest when base64
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
PerfectSlayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round of comments for the core part. I will let IDM review the instrumentation part.
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/InstrumenterModule.java
Outdated
Show resolved
Hide resolved
dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/TagsAssert.groovy
Outdated
Show resolved
Hide resolved
dd-trace-core/src/main/java/datadog/trace/llmobs/writer/ddintake/LLMObsSpanMapper.java
Outdated
Show resolved
Hide resolved
...ava-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy
Outdated
Show resolved
Hide resolved
da72f90 to
3468137
Compare
6fa5b22 to
aea89e3
Compare
c1b0c81 to
37a8fd1
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37a8fd12f8
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
dd-trace-core/src/main/java/datadog/trace/llmobs/writer/ddintake/LLMObsSpanMapper.java
Show resolved
Hide resolved
PerfectSlayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking for for LP. I left aside the instrumentation part.
Thanks for the follow up changes 👍
...ava-agent/testing/src/main/groovy/datadog/trace/agent/test/server/http/TestHttpServer.groovy
Outdated
Show resolved
Hide resolved
96ac8e8 to
d9a6fcf
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d9a6fcfbce
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public static <T> CompletableFuture<HttpResponseFor<T>> wrapFuture( | ||
| CompletableFuture<HttpResponseFor<T>> future, | ||
| AgentSpan span, | ||
| BiConsumer<AgentSpan, T> decorate) { | ||
| return future | ||
| .thenApply(response -> wrap(response, span, decorate)) | ||
| .whenComplete((_r, t) -> DECORATE.finishSpan(span, t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid finishing async spans before response parsing
The wrapFuture path finishes the span as soon as the CompletableFuture completes successfully, but the OpenAI async APIs return a response that is parsed later; the output decorators run in parse(). That means for any async create call (chat/completions/responses) where the future resolves before parse() is invoked—which is the normal usage—the span is already finished and the output tags/metrics set in parse() can be dropped or ignored. This effectively loses LLMObs output data for async calls. Consider only finishing on error in whenComplete and letting parse()/close() finish the span on success.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 we have tests on async requests though, which seem to be asserting the correct tags are applied. Is it that we do all the operations in a row in the test, which is not representative of a "real world" use case ?
Or maybe chatgpt's concerns are unfounded
What Does This Do
Adds openai-java v3.0+ instrumentation for completions, chat completions, embeddings, and responses.
APM shared tests:
LLMObs shared tests 14*/15:
test_chat_completion_telemetryFAILED because the shared test expects a namespace for the entire batch, but it should allow the namespace to be part of the metric data. Since Java batches telemetry data across subsystems and cannot guarantee that all the data belongs to the same namespace.Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: AIDM-163