Bug: Streaming responses don't capture `response_id` or `model_version`

Open Beginner friendly
#5,812 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
observability

Research direction

Start in sentry_sdk/integrations/google_genai/streaming.py at accumulate_streaming_response(), then compare the response metadata handling in utils.py:886-890. Check each streaming chunk for response_id and model_version, and add a test verifying both span fields are populated for streaming responses.

Written by the indexing model from the issue text.

Description

Bug Python Spans

Problem

In streaming.py, the accumulate_streaming_response() function initializes response_id and model to None (lines 53-54) but never populates them from the streaming chunks. The accumulation loop (lines 56-83) never reads chunk.response_id or chunk.model_version.

This means streaming responses will always have null for gen_ai.response.id and gen_ai.response.model.

The non-streaming path correctly captures both in utils.py:886-890:

if getattr(response, "response_id", None):
    span.set_data(SPANDATA.GEN_AI_RESPONSE_ID, response.response_id)
if getattr(response, "model_version", None):
    span.set_data(SPANDATA.GEN_AI_RESPONSE_MODEL, response.model_version)

Files

  • sentry_sdk/integrations/google_genai/streaming.pyaccumulate_streaming_response()

Acceptance Criteria

  • Streaming chunks are checked for response_id and model_version
  • gen_ai.response.id and gen_ai.response.model are populated on streaming spans
  • Test added to verify streaming responses capture these fields
Dominant language
Python
Stars
2.2k
Forks
672
Avg merge
1d 13m
Merged PRs (30d)
212

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-python

All issues in getsentry/sentry-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.