Repository navigation
Classify OpenAI chat and embeddings errors by service code - #20780
Merged
Merged
Conversation
Pull request dashboard statusMerged · refreshed 2026-10-21 06:09 UTC Status above doesn't look right?
|
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add meaningful getErrorType overrides for OpenAI chat and embeddings
Classify OpenAI chat and embeddings errors by service code
Oct 20, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No blocking defects were identified; the remaining feedback is a nonblocking test-assertion improvement.
1 open issue
What changed in this PR
Improves OpenAI chat and embeddings error classification in spans and operation-duration metrics.
Changes:
- Uses allowlisted service codes while preserving exception-class fallback.
- Adds sync, async, and streaming error tests.
- Documents classification behavior.
| File | Description |
|---|---|
| instrumentation/openai/openai-java-1.1/library/src/test/java/io/opentelemetry/instrumentation/openai/v1_1/ServiceErrorTest.java | Tests service-code classification and fallback telemetry. |
| instrumentation/openai/openai-java-1.1/library/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/OpenAiErrorType.java | Adds shared service-code classification. |
| instrumentation/openai/openai-java-1.1/library/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/EmbeddingAttributesGetter.java | Applies classification to embeddings. |
| instrumentation/openai/openai-java-1.1/library/src/main/java/io/opentelemetry/instrumentation/openai/v1_1/ChatAttributesGetter.java | Applies classification to chat. |
| instrumentation/openai/openai-java-1.1/library/README.md | Documents supported codes and fallback behavior. |
Review effort: Balanced
Reject unexpected attributes and check the streaming flag plus partial-response ID and model for the existing error scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
trask
reviewed
Oct 20, 2026
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Set base64 encoding explicitly and include it in exact span assertions so the service-code tests work with both minimum and latest SDK defaults. Production telemetry and error classification are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
trask
reviewed
Oct 21, 2026
Co-authored-by: trask <218610+trask@users.noreply.github.com>
trask
reviewed
Oct 21, 2026
Co-authored-by: trask <218610+trask@users.noreply.github.com>
trask
reviewed
Oct 21, 2026
trask
reviewed
Oct 21, 2026
trask
marked this pull request as ready for review
October 21, 2026 03:27
trask
approved these changes
Oct 21, 2026
laurit
approved these changes
Oct 21, 2026
14 of 25 tasks
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.

Use structured provider error codes for
error.typeon chat and embeddings spans and operation-duration metrics, for examplecontext_length_exceededinstead ofcom.openai.errors.BadRequestException.