Skip to content

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

Open

Description

@planetf1

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 feat(telemetry): close five OTel GenAI semantic convention emission gaps (#1035) #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 refactor: rename tracing env vars to plural and align with OTel semconv #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

Related

Activity

  1. added
    area/backends
    area/telemetry
    area/tools
    enhancement
    on May 20, 2026
  2. added
    p2
    on Jun 18, 2026
  3. self-assigned this
    on Aug 17, 2026
  4. removed their assignment
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/backendsarea/telemetryarea/toolsenhancementp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions