Skip to content

Classify OpenAI chat and embeddings errors by service code - #20780

Merged
laurit merged 9 commits into
mainfrom
copilot/openai-error-type-overrides
Oct 21, 2026
Merged

laurit merged 9 commits into
mainfrom
copilot/openai-error-type-overrides

Conversation

Copilot AI commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Use structured provider error codes for error.type on chat and embeddings spans and operation-duration metrics, for example context_length_exceeded instead of com.openai.errors.BadRequestException.

  • Classification: Report provider codes verbatim, including empty or whitespace-only strings and codes from OpenAI-compatible services. Retain exception-class fallback for transport failures and missing or malformed codes; never classify from messages.
  • Scope: Cover sync/async calls, streaming request failures, and existing async SSE terminal callbacks. Leave lifecycle, status, and cancellation policies unchanged; exclude Responses API errors and blocking SSE iteration failures.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-21 06:09 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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
Copilot AI requested a review from trask October 20, 2026 19:11
@trask
trask requested a balanced review from Copilot October 20, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrowly scoped classifier and telemetry integration have focused coverage and no unresolved findings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI requested a review from trask October 20, 2026 22:42
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>
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI requested a review from trask October 21, 2026 02:55
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot AI requested a review from trask October 21, 2026 03:15
Comment thread instrumentation/openai/openai-java-1.1/library/README.md Outdated
Comment thread instrumentation/openai/openai-java-1.1/library/README.md Outdated
@trask
trask marked this pull request as ready for review October 21, 2026 03:27
@trask
trask requested a review from a team as a code owner October 21, 2026 03:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes preserve fallback and lifecycle behavior, with targeted regression coverage and no unresolved findings.

No open issues 🎉

Review effort: Balanced

@laurit
laurit merged commit 2159447 into main Oct 21, 2026
70 checks passed
@laurit
laurit deleted the copilot/openai-error-type-overrides branch October 21, 2026 06:09
@trask trask mentioned this pull request Oct 22, 2026
14 of 25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants