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

Abierto
#2,055 1 comentario 0 reacciones 0 asignados Ver en GitHub

@agustin18 ya está trabajando en esto.

Desde el 3/11/2026.

  • #2056 de @agustin18 — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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?

Lenguaje dominante
Python
Estrellas
4.1k
Forks
915
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anthropics/anthropic-sdk-python

Todos los issues de anthropics/anthropic-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.