Skip to content

fix(otel): emit trace_output as span attribute instead of event#9255

Merged
DOsinga merged 1 commit into
mainfrom
fix/8586-otel-trace-output-span-attr
May 18, 2026
Merged

fix(otel): emit trace_output as span attribute instead of event#9255
DOsinga merged 1 commit into
mainfrom
fix/8586-otel-trace-output-span-attr

Conversation

@DOsinga
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga commented May 15, 2026

Summary

trace_output was emitted via tracing::info!() which becomes an OTEL event (a log line attached to the span), not a span attribute. Observability backends like MLflow and Langfuse (via OTEL ingestion) look for span attributes to populate input/output fields, so the assistant output was invisible to them.

Changes

  • Declare trace_output as a field on reply_stream_span so it can accept a recorded value
  • Replace tracing::info!(trace_output = ...) with tracing::Span::current().record("trace_output", ...) to set it as a proper span attribute

The Langfuse custom layer's on_record and on_event both call handle_record with the same metadata, so this change is transparent to the Langfuse-specific path.

Fixes #8586

trace_output was emitted via tracing::info!() which becomes an OTEL
event (log line on the span), not a span attribute. Observability
backends like MLflow and Langfuse (via OTEL ingestion) look for span
attributes, so the output was invisible to them.

Declare trace_output as a field on reply_stream_span and use
Span::record() so it becomes a proper OTEL span attribute. The
Langfuse custom layer handles both paths identically (on_record and
on_event both call handle_record), so this is a no-op for that path.

Fixes #8586

Signed-off-by: Douwe Osinga <douwe@squareup.com>
@DOsinga DOsinga added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 3a2f4ea May 18, 2026
20 of 22 checks passed
@DOsinga DOsinga deleted the fix/8586-otel-trace-output-span-attr branch May 18, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not emitting the fields in a way that observability integrations would use as input/output

2 participants