Class OpenTelemetryClientTransportWrapper
java.lang.Object
org.a2aproject.sdk.extras.opentelemetry.client.OpenTelemetryClientTransportWrapper
- All Implemented Interfaces:
Comparable<ClientTransportWrapper>, ClientTransportWrapper
OpenTelemetry client transport wrapper that adds distributed tracing to A2A client calls.
This wrapper is automatically discovered via Java's ServiceLoader mechanism.
To enable tracing, add a Tracer instance to the transport configuration:
ClientTransportConfig config = new JSONRPCTransportConfig();
config.setParameters(Map.of(
OpenTelemetryClientTransportWrapper.OTEL_TRACER_KEY,
openTelemetry.getTracer("my-service")
));
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConfiguration key for the OpenTelemetry Tracer instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintpriority()Returns the priority of this wrapper.wrap(ClientTransport transport, ClientTransportConfig<?> config) Wraps the given transport with additional functionality.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ClientTransportWrapper
compareTo
-
Field Details
-
OTEL_TRACER_KEY
Configuration key for the OpenTelemetry Tracer instance. Value must be of typeTracer.- See Also:
-
-
Constructor Details
-
OpenTelemetryClientTransportWrapper
public OpenTelemetryClientTransportWrapper()
-
-
Method Details
-
wrap
Description copied from interface:ClientTransportWrapperWraps the given transport with additional functionality.Implementations should check the configuration to determine if they should actually wrap the transport. If the wrapper is not applicable (e.g., required configuration is missing), return the original transport unchanged.
- Specified by:
wrapin interfaceClientTransportWrapper- Parameters:
transport- the transport to wrapconfig- the transport configuration, may contain wrapper-specific parameters- Returns:
- the wrapped transport, or the original if wrapping is not applicable
-
priority
public int priority()Description copied from interface:ClientTransportWrapperReturns the priority of this wrapper. Higher priority wrappers are applied first (wrap the transport earlier, resulting in being the outermost wrapper).Default priority is 0. Suggested ranges:
- 1000+ : Critical infrastructure (security, authentication)
- 500-999: Observability (tracing, metrics, logging)
- 100-499: Enhancement (caching, retry logic)
- 0-99: Optional features
- Specified by:
priorityin interfaceClientTransportWrapper- Returns:
- the priority value, higher values = higher priority
-