Set `gen_ai.response.id` on `gen_ai.chat` spans

Open Beginner friendly
#5,833 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in sentry_sdk/integrations/pydantic_ai/spans/ai_client.py at update_ai_client_span(), then inspect pydantic-ai's ModelResponse and SPANDATA.GEN_AI_RESPONSE_ID in consts.py. Confirm that response_id is extracted from the response and that completed gen_ai.chat spans expose gen_ai.response.id for correlation with provider dashboards and logs.

Written by the indexing model from the issue text.

Description

Improvement Python Spans

Extract response_id from pydantic-ai's ModelResponse and set it as gen_ai.response.id in update_ai_client_span() in sentry_sdk/integrations/pydantic_ai/spans/ai_client.py.

This is a recommended OTel attribute, useful for correlating spans with provider dashboards/logs. We already have SPANDATA.GEN_AI_RESPONSE_ID defined in consts.py.

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.