Class OpenTelemetryClientPropagatorTransportWrapper

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

public class OpenTelemetryClientPropagatorTransportWrapper extends Object implements ClientTransportWrapper
OpenTelemetry client transport wrapper that injects W3C Trace Context headers into outbound A2A client requests.

This wrapper is automatically discovered via Java's ServiceLoader mechanism. To enable context propagation, add an OpenTelemetry instance to the transport configuration:

ClientTransportConfig config = new JSONRPCTransportConfig();
config.setParameters(Map.of(
    OpenTelemetryClientPropagatorTransportWrapper.OTEL_OPEN_TELEMETRY_KEY,
    openTelemetry
));
  • Field Details

    • OTEL_OPEN_TELEMETRY_KEY

      public static final String OTEL_OPEN_TELEMETRY_KEY
      Configuration key for the OpenTelemetry instance used for context propagation.
      See Also:
  • Constructor Details

    • OpenTelemetryClientPropagatorTransportWrapper

      public OpenTelemetryClientPropagatorTransportWrapper()
  • 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