Skip to content

fix(tracing): otel tracing input/output message onModelCall#2156

Open
rudy2steiner wants to merge 1 commit into
agentscope-ai:mainfrom
rudy2steiner:telemetry
Open

fix(tracing): otel tracing input/output message onModelCall#2156
rudy2steiner wants to merge 1 commit into
agentscope-ai:mainfrom
rudy2steiner:telemetry

Conversation

@rudy2steiner

Copy link
Copy Markdown
Contributor

Description

Fixes #1939 model-call OpenTelemetry tracing to record GenAI semantic input/output content on chat spans, including messages, reasoning, tool calls, tool results, tool definitions, request options et.

Main Changes

  • Record GenAI semantic input/output attributes on model-call span in OtelTracingMiddleware#onModelCall .
  • Add tests for this change in OtelTracingMiddlewareTest.

@rudy2steiner rudy2steiner requested a review from a team July 12, 2026 09:52
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.92090% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...agentscope/core/tracing/OtelTracingMiddleware.java 81.92% 6 Missing and 26 partials ⚠️

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/core Core library: agentscope-core (general) labels Jul 13, 2026

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds GenAI semantic convention attributes for input/output messages on the chat span in OtelTracingMiddleware.onModelCall(). The implementation is clean and well-structured: input messages (with roles, content blocks, tool definitions) are serialized on the SpanBuilder before startSpan(), streamed output (text, reasoning, tool calls) is accumulated via doOnNext and recorded in setModelResponseAttributes when ModelCallEndEvent arrives — correctly before span.end() in doOnComplete. Test coverage is solid. The main concern is the lack of an opt-out mechanism for content recording, which could expose sensitive data in production environments.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

This PR adds GenAI semantic convention attributes for input/output messages on the chat span in OtelTracingMiddleware.onModelCall(). The implementation is clean and well-structured: input messages (with roles, content blocks, tool definitions) are serialized on the SpanBuilder before startSpan(), streamed output (text, reasoning, tool calls) is accumulated via doOnNext and recorded in setModelResponseAttributes when ModelCallEndEvent arrives — correctly before span.end() in doOnComplete. Test coverage is solid. The main concern is the lack of an opt-out mechanism for content recording, which could expose sensitive data in production environments.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@rudy2steiner

rudy2steiner commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@jujn could you review this PR when you have time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core library: agentscope-core (general) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OtelTracingMiddleware does not record message content — input/output always empty in OTLP backends

2 participants