Skip to content

[opentelemetry-instrumentation-genai-openai] Do not record gen_ai.request.stream on fetch_response spans - #709

Merged
lmolkova merged 1 commit into
open-telemetry:mainfrom
lmolkova:openai-fetch-response-remove-stream
Sep 13, 2026
Merged

lmolkova merged 1 commit into
open-telemetry:mainfrom
lmolkova:openai-fetch-response-remove-stream

Conversation

@lmolkova

@lmolkova lmolkova commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Removes setting gen_ai.request.stream on fetch_response spans in the OpenAI instrumentation.

Per fetch_response semantic conventions, fetch_response operations do not define gen_ai.request.stream.

Proposing to add it to semconv in open-telemetry/semantic-conventions-genai#513

I'd prefer to proceed with this change anyway since I'd like to codegen most of utils and it's a blocker.

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 implementation and corresponding tests align with the fetch-response semantic conventions.

Pull request overview

Removes the unsupported gen_ai.request.stream attribute from OpenAI fetch_response spans.

Changes:

  • Stops passing request_stream to fetch-response invocations.
  • Updates synchronous and asynchronous tests.
  • Adds a changelog entry.
File summaries
File Description
instrumentation/opentelemetry-instrumentation-genai-openai/tests/test_utils.py Verifies the stream attribute is absent.
instrumentation/opentelemetry-instrumentation-genai-openai/tests/test_responses.py Updates synchronous response tests.
instrumentation/opentelemetry-instrumentation-genai-openai/tests/test_async_responses.py Updates asynchronous response tests.
instrumentation/opentelemetry-instrumentation-genai-openai/src/opentelemetry/instrumentation/genai/openai/patch_responses.py Removes fetch-response stream attribute setup.
instrumentation/opentelemetry-instrumentation-genai-openai/.changelog/709.fixed Documents the fix.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lmolkova
lmolkova marked this pull request as ready for review September 13, 2026 22:43
@lmolkova
lmolkova requested a review from a team as a code owner September 13, 2026 22:43
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-17 06:33 UTC

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

@lmolkova
lmolkova added this pull request to the merge queue Sep 13, 2026
Merged via the queue into open-telemetry:main with commit 5bf108e Sep 13, 2026
75 checks passed
@lmolkova
lmolkova deleted the openai-fetch-response-remove-stream branch September 13, 2026 23:51
eternalcuriouslearner added a commit to eternalcuriouslearner/opentelemetry-python-genai that referenced this pull request Sep 21, 2026
The attribute is not part of the fetch_response span in the GenAI semantic
conventions; a resumed fetch is identified by gen_ai.request.stream_cursor.
Matches the same removal made for the OpenAI package in open-telemetry#709.

Also name the changelog fragment after the PR and sort imports.

Assisted-by: Claude Opus 5
eternalcuriouslearner added a commit to eternalcuriouslearner/opentelemetry-python-genai that referenced this pull request Sep 22, 2026
The attribute is not part of the fetch_response span in the GenAI semantic
conventions; a resumed fetch is identified by gen_ai.request.stream_cursor.
Matches the same removal made for the OpenAI package in open-telemetry#709.

Also name the changelog fragment after the PR and sort imports.

Assisted-by: Claude Opus 5
lmolkova pushed a commit to lmolkova/opentelemetry-python-genai that referenced this pull request Sep 22, 2026
…n-telemetry#755)

* feat(google-genai): instrument interactions.get as fetch_response

Emit a `fetch_response` span for `client.interactions.get`, sync and async,
covering non-streaming, streamed and resumed-streamed retrieval. A fetch
performs no inference, so the fetched interaction's token counts are
deliberately not reported.

Fixes open-telemetry#561

Assisted-by: Claude Opus 5

* fix(google-genai): drop gen_ai.request.stream from fetch_response spans

The attribute is not part of the fetch_response span in the GenAI semantic
conventions; a resumed fetch is identified by gen_ai.request.stream_cursor.
Matches the same removal made for the OpenAI package in open-telemetry#709.

Also name the changelog fragment after the PR and sort imports.

Assisted-by: Claude Opus 5

* fix(google-genai): address review feedback on interactions.get

- Only serialize tool definitions when content capture is on; the attribute
  is opt-in, so the work is otherwise discarded.
- Widen `_on_stream_error` to `BaseException`, matching the base hook and the
  cancellation it actually receives.
- Report the HTTP status as `error.type` for interactions errors: they raise
  from the SDK's own hierarchy, unrelated to `google.genai.errors.APIError`,
  and carry the status as `status_code`.
- Cover `aio.interactions.with_streaming_response.get`.
- Mark the two synthesized cassettes for re-recording, and drop a stray
  interaction a record run appended to the failed-status one.

Assisted-by: Claude Opus 5

* style: format the new error-type test

Assisted-by: Claude Opus 5
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.

3 participants