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

Aperta
#1,073 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
observability-sre, python
Ambito
observability

Direzione di ricerca

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.

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

Descrizione

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)
Lingua principale
Python
Stelle
1.8k
Fork
161
Merge medio
4g 3h
PR unite (30g)
45

Preparare l'ambiente

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

Tutte le issue di generative-computing/mellea

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.