feat(telemetry): emit gen_ai.input/output.messages content events from tracing plugin (post-#1045)

Abierto
#1,073 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
observability-sre, python

Línea de trabajo

Blocked until #1045 merges, since BackendTracingPlugin and GenerationPostCallPayload do not exist yet. Once they do, start in mellea/telemetry/tracing.py, where is_content_tracing_enabled() and add_span_event() already exist, and read how the plugin receives the conversation and output. Done means content span events are emitted only when the opt-in flag is set, with content off by default. Confirm the env var name first, since #1046 renames it.

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

Descripción

area/backends area/telemetry area/tools enhancement p2

Problem

Gap 5 from #1035: Mellea does not emit chat content span events, so the conversation transcript is invisible in OTel backends. Metadata (tokens, model, latency) is present on backend spans but prompts and responses are not.

Per the OTel GenAI semconv, content capture should use span events with these names, each carrying structured role + content:

  • gen_ai.system.message
  • gen_ai.user.message
  • gen_ai.assistant.message
  • gen_ai.tool.message
  • gen_ai.choice

Additionally, OpenInference-compatible system instruction capture:

  • gen_ai.system_instructions

Why deferred from PR #1036

The component-level approach (passing conversation/output_text through finalize_backend_span) required changes to all 5 backends and was withdrawn as too much churn. After #1045, BackendTracingPlugin receives GenerationPostCallPayload which contains the conversation and output — no backend changes needed at all.

Approach

After #1045 lands and BackendTracingPlugin exists:

  1. In BackendTracingPlugin, check is_content_tracing_enabled() before emitting.
  2. If enabled, call the existing add_span_event() helper (already wired in mellea/telemetry/tracing.py from PR #1036) to emit gen_ai.user.message, gen_ai.assistant.message, etc. from GenerationPostCallPayload.
  3. Content capture remains off by default — opt in via MELLEA_TRACE_CONTENT (renamed MELLEA_TRACES_CONTENT under #1046) or OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT.

The infrastructure is already in place from PR #1036: is_content_tracing_enabled(), add_span_event(), and the _TRACE_CONTENT_ENABLED flag.

Prerequisites

  • #1045 (Phase 1 plugin/hook pattern) must merge first — BackendTracingPlugin and GenerationPostCallPayload are not available until then.

Related

  • Epic #444 Phase 2 — alongside #1035, #1067
  • PR #1036 (infrastructure landed; content emission deferred)
  • #1046 (env var rename — MELLEA_TRACE_CONTENT → MELLEA_TRACES_CONTENT)
Lenguaje dominante
Python
Estrellas
1.8k
Forks
161
Merge medio
4 d 3 h
PR fusionados (30 d)
45

Preparar el entorno

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 generative-computing/mellea

Todos los issues de generative-computing/mellea

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.