-
Notifications
You must be signed in to change notification settings - Fork 109
feat: Add telemetry support. #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @ehsavoie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates OpenTelemetry into the A2A Java SDK, providing robust distributed tracing capabilities. The changes enable automatic span creation for both client-initiated and server-processed A2A requests, offering deeper visibility into the flow of operations. This enhancement is crucial for monitoring, troubleshooting, and understanding the performance characteristics of applications built with the SDK. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for OpenTelemetry, which is a great addition for observability. The implementation introduces a new opentelemetry extras module and integrates tracing on both the client and server sides. On the client side, it uses reflection for optional wrapping, and on the server side, it uses CDI interceptors with a new @Trace annotation. My review focuses on improving the robustness and maintainability of this new feature. I've found a few critical issues, such as a ClassCastException in an attribute extractor and silent exception swallowing that could make debugging difficult. I've also identified several opportunities for code cleanup, such as fixing typos, removing duplicated code, and improving the design of the CDI interceptor to better support dependency injection. Addressing these points will make the OpenTelemetry integration more solid and easier to maintain.
transport/rest/src/main/java/io/a2a/transport/rest/handler/RestAttributeExtractor.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
extras/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/SpanInterceptor.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
extras/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/SpanInterceptor.java
Outdated
Show resolved
Hide resolved
transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcHandler.java
Outdated
Show resolved
Hide resolved
transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpctAttributeExtractor.java
Outdated
Show resolved
Hide resolved
brunobat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to decide if you are creating your own instrumentation annotations and API or if you just reuse the ones provided by OTel.
Also, the attribute names, should follow these semantic conventions, as much as possible: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans/
server-common/src/main/java/io/a2a/server/interceptors/AttributeExtractor.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Outdated
Show resolved
Hide resolved
examples/helloworld/client/src/main/java/io/a2a/examples/helloworld/HelloWorldClient.java
Show resolved
Hide resolved
7661dd6 to
893ce8b
Compare
22a2af4 to
d35543a
Compare
kabir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things which may or may not be needed :-)
extras/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/SpanInterceptor.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/requesthandlers/RequestHandlerAttributeExtractor.java
Show resolved
Hide resolved
transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcAttributeExtractor.java
Show resolved
Hide resolved
transport/jsonrpc/src/main/java/io/a2a/transport/jsonrpc/handler/JSONRPCAttributeExtractor.java
Show resolved
Hide resolved
transport/rest/src/main/java/io/a2a/transport/rest/handler/RestAttributeExtractor.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, @ehsavoie it looks like you are adding Otel tracing to the example. But I don't know how to enable this etc.
Can you update the README with instructions?
Maybe we could also make this example testable in the CI, like we do for the cloud-deployment one?
Also, it would be good to have some tests in the extras module
0eee5a4 to
49b8dd0
Compare
kabir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehsavoie 2 small things.
If the JBang validator is tricky, open an issue and link it here
examples/helloworld/client/src/main/java/io/a2a/examples/helloworld/HelloWorldRunner.java
Outdated
Show resolved
Hide resolved
...as/opentelemetry/src/main/java/io/a2a/extras/opentelemetry/OpenTelemetryClientTransport.java
Show resolved
Hide resolved
0a41c0e to
badca86
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces OpenTelemetry distributed tracing support across the A2A Java SDK client and server, along with multi-protocol support (JSONRPC, GRPC, HTTP+JSON) for the helloworld example. Key changes include adding a new a2a-java-sdk-opentelemetry module, which provides ClientTransportWrapper and CDI SpanInterceptor implementations to automatically instrument client and server operations. The ClientBuilder was enhanced to support transport wrapping, and ClientTransportConfig now includes a parameters map for passing tracing context. The helloworld example client and server were updated to demonstrate dynamic protocol selection and OpenTelemetry integration, with corresponding pom.xml and README.md changes. Review comments highlighted the need to return an unmodifiable map for ClientTransportConfig.getParameters() to ensure immutability, to use public constants for OpenTelemetry parameter keys for better maintainability, and to simplify the application.properties file by consolidating quarkus.agentcard.protocol definitions.
client/transport/spi/src/main/java/io/a2a/client/transport/spi/ClientTransportConfig.java
Show resolved
Hide resolved
examples/helloworld/client/src/main/java/io/a2a/examples/helloworld/HelloWorldClient.java
Outdated
Show resolved
Hide resolved
examples/helloworld/server/src/main/resources/application.properties
Outdated
Show resolved
Hide resolved
…d null safety Added OpenTelemetry integration for distributed tracing across the A2A SDK: - Added @trace annotation for CDI interceptors to create spans on method invocations - Created SpanInterceptor with robust CDI proxy handling supporting 5 proxy patterns - Added InvocationContext record for capturing method invocation details with: * Null safety annotations (@NonNull/@nullable) * Comprehensive JavaDoc documentation * Specific exception declarations (IllegalAccessException, InvocationTargetException) - Implemented attribute extractors for all transport types: * GrpcAttributeExtractor with null-safe gRPC context key access * JsonRPCAttributeExtractor with method name extraction * RestAttributeExtractor with conditional attribute building * RequestHandlerAttributeExtractor for default request handler - Added ClientTransportWrapper SPI for wrapping transport operations - Created OpenTelemetryClientTransport decorator supporting: * All A2A client methods (sendMessage, getTask, listTasks, etc.) * Streaming operations with event consumer wrapping * Error consumer instrumentation * Helper methods to eliminate code duplication - Updated ClientBuilder to apply transport wrappers via ServiceLoader - Added comprehensive tests for OpenTelemetryClientTransport - Added tests for SpanInterceptor CDI proxy handling - Added tests for AttributeExtractor null safety - All attribute extractors include defensive null checks preventing NPE - Updated HelloWorld example with OpenTelemetry integration: * Added OTEL dependencies and configuration * Configured trace export to console * Added README documentation for running with telemetry * Server now includes @trace annotation on agent method * Protocol can be selected - Added extras/opentelemetry module with dependencies - Updated BOM with OpenTelemetry extras - Added CDI beans.xml and ServiceLoader configuration - Updated .gitignore for IDE and build artifacts Fixes a2aproject#388 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Adding support for OpenTelemetry
Fixes #388 🦕