Repository navigation
feat(opentelemetry): add streaming span lifecycle and operation metrics - #1236
Conversation
acd33c1 to
3c2318d
Compare
kabir
left a comment
There was a problem hiding this comment.
Found two blocking telemetry gaps:
-
gRPC client streams never produce the terminal span or duration metric. The new wrapper relies on its
errorConsumerbeing called withnullon successful completion, but gRPCEventStreamObserver.onCompleted()is a no-op. Successful gRPC streams therefore omit<method>-endandgen_ai.client.operation.duration. Please signal completion through the callback (or add a completion callback to the client transport contract) and cover it with a gRPC integration test. -
gRPC server streams commonly bypass the new terminal instrumentation. The decorator forwards the underlying subscription directly. The gRPC handler cancels that subscription when it sends a final task-status event, then closes the wire stream without invoking the decorator subscriber’s
onComplete(). This skips the server<method>-endspan and streaming-duration histogram for the normal final-status path, as well as client cancellation. Please interceptSubscription.cancel()or ensure the handler signals completion through the decorated subscriber.
kabir
left a comment
There was a problem hiding this comment.
- P1 — REST streams never finish the new client telemetry. OpenTelemetryClientTransport.java:173 relies on errorConsumer.accept(null) to create the closing span and record the duration. RestTransport currently discards its SSE completion callback for both streaming methods, so a normally completed REST stream produces neither the -end span nor gen_ai.client.operation.duration. Update REST completion handlers to signal the listener/consumer with null (as JSON-RPC now does), and add a REST completion test.
- Per-event child spans and terminal closing span for streaming methods - Duration histograms for client (gen_ai.client.operation.duration) and server (gen_ai.agent.a2a.streaming.duration) - Signal REST stream completion to terminal consumer for proper span closing Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>

Fixes #1216 🦕