getsentry / getsentry/sentry-python

Add `gen_ai.request.choice.count` attribute (candidate_count)

オープン
#5,816 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
Improvement Python Spans
主要言語
Python
スター
2.2k
フォーク
669
平均マージ
1日 40分
マージ済み PR(30日)
212

説明

## Problem

OTel GenAI semconv conditionally requires `gen_ai.request.choice.count` "if available and != 1". Google's `GenerateContentConfig` has `candidate_count` but it is not captured.

## Context

This attribute helps understand when users request multiple response candidates, which impacts token usage and cost.

## Files

* `sentry_sdk/integrations/google_genai/utils.py` — `set_span_data_for_request()`
* `sentry_sdk/consts.py` — uses `SPANDATA.GEN_AI_CHOICE` which maps to `gen_ai.choice`

## Acceptance Criteria

* `candidate_count` from config is captured on the span when present and != 1
* Test added to verify the attribute is set

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。