Class OpenTelemetryClientTransportWrapper

java.lang.Object
org.a2aproject.sdk.extras.opentelemetry.client.OpenTelemetryClientTransportWrapper
All Implemented Interfaces:
Comparable<ClientTransportWrapper>, ClientTransportWrapper

public class OpenTelemetryClientTransportWrapper extends Object implements 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 Details

    • OTEL_TRACER_KEY

      public static final String OTEL_TRACER_KEY
      Configuration key for the OpenTelemetry Tracer instance. Value must be of type Tracer.
      See Also:
  • Constructor Details

    • OpenTelemetryClientTransportWrapper

      public OpenTelemetryClientTransportWrapper()
  • Method Details

    • wrap

      public ClientTransport wrap(ClientTransport transport, ClientTransportConfig<?> config)
      Description copied from interface: ClientTransportWrapper
      Wraps 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:
      wrap in interface ClientTransportWrapper
      Parameters:
      transport - the transport to wrap
      config - 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: ClientTransportWrapper
      Returns 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:
      priority in interface ClientTransportWrapper
      Returns:
      the priority value, higher values = higher priority