Class ObservationGrpcClientInterceptor

java.lang.Object
io.micrometer.core.instrument.binder.grpc.ObservationGrpcClientInterceptor
All Implemented Interfaces:
io.grpc.ClientInterceptor

public class ObservationGrpcClientInterceptor extends Object implements io.grpc.ClientInterceptor
A gRPC client interceptor that works with Observation.

Usage:

 ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080)
     .intercept(new ObservationGrpcClientInterceptor(observationRegistry))
     .build();
 channel.newCall(method, options);
 
The instrumentation is based on the behavior of Spring Cloud Sleuth and Brave.
Since:
1.10.0
  • Constructor Details

    • ObservationGrpcClientInterceptor

      public ObservationGrpcClientInterceptor(io.micrometer.observation.ObservationRegistry registry)
  • Method Details

    • interceptCall

      public <ReqT, RespT> io.grpc.ClientCall<ReqT,RespT> interceptCall(io.grpc.MethodDescriptor<ReqT,RespT> method, io.grpc.CallOptions callOptions, io.grpc.Channel next)
      Specified by:
      interceptCall in interface io.grpc.ClientInterceptor
    • setCustomConvention

      public void setCustomConvention(@Nullable GrpcClientObservationConvention customConvention)
      Parameters:
      customConvention - a custom convention