getsentry / getsentry/sentry-python

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

Aperta
#5,816 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Improvement Python Spans
Lingua principale
Python
Stelle
2.2k
Fork
669
Merge medio
1g 1h
PR unite (30g)
213

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.