Built-in tracing: no gen_ai.response.finish_reasons, and status OK on success

Aperta
#2,055 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@agustin18 ci sta già lavorando.

Dal 3/11/2026.

  • #2056 di @agustin18 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
observability

Direzione di ricerca

Start with lib/_tracing/_work.py and inspect the Anthropic message span attributes and success status behavior described in the issue. Check the tracing tests for expected GenAI response attributes and span status, then verify the suggested finish reason and success status changes there; the issue notes Bedrock and Vertex clients are untested. Done means the finish reason follows the GenAI convention and successful spans leave status unset. A linked open pull request already addresses this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In anthropic 2.4.0 the anthropic.messages.create span records the stop reason as anthropic.message.stop_reason and sets no gen_ai.response.finish_reasons. Every other response attribute follows the GenAI conventions, so a backend that reads them finds everything except the finish reason.

The span also ends with status OK on success (lib/_tracing/_work.py line 68). Recording Errors says: "Span Status Code MUST be left unset if the instrumented operation has ended without any errors" (v1.44.0).

Tokens, cache counts, error.type and early-exit spans all matched the wire: https://plexito-de.github.io/spantruth/#anthropic-sdk--anthropic--basic--finish_reasons. Not tested: the Bedrock and Vertex clients.

Suggested fix: set gen_ai.response.finish_reasons to [stop_reason] beside the Anthropic attribute, and leave the status unset on success.

Since 1.14.0 the SDK traces whenever a tracer provider is registered, so an app with an instrumentation library (OpenLLMetry, OpenInference) reports each call on two spans with usage. Is ANTHROPIC_OPEN_TELEMETRY=false the intended answer there?

Lingua principale
Python
Stelle
4.1k
Fork
915
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anthropics/anthropic-sdk-python

Tutte le issue di anthropics/anthropic-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.