Class GrpcObservationFactory

java.lang.Object
io.micronaut.micrometer.observation.grpc.GrpcObservationFactory

@Factory @Internal @Requires(classes=io.micrometer.core.instrument.binder.grpc.ObservationGrpcServerInterceptor.class) @Requires(beans=io.micrometer.observation.ObservationRegistry.class) public class GrpcObservationFactory extends Object
Registers Micrometer's gRPC observation interceptors as beans, so that micronaut-grpc installs them on the server and on every channel. Each call becomes a grpc.server or grpc.client observation, which the observation handlers turn into timers and, with Micrometer Tracing, spans.

The gRPC metrics binder of micronaut-micrometer-core (micronaut.metrics.binders.grpc.*, enabled by default) registers Micrometer's MetricCollectingServerInterceptor and MetricCollectingClientInterceptor, which also record metrics for every call. When both are present, disable the binder with micronaut.metrics.binders.grpc.enabled=false so that calls are not measured twice.

Since:
6.1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Enables observations of gRPC client calls.
    static final int
    The order of the observation interceptors: ahead of interceptors with the default order, so that calls they reject or fail are observed too.
    static final String
    Enables observations of gRPC server calls.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.grpc.ClientInterceptor
    grpcClientObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcClientObservationConvention convention)
    Creates the client observation interceptor.
    protected io.grpc.ServerInterceptor
    grpcServerObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcServerObservationConvention convention)
    Creates the server observation interceptor.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SERVER_ENABLED

      public static final String SERVER_ENABLED
      Enables observations of gRPC server calls. Defaults to true.
      See Also:
    • CLIENT_ENABLED

      public static final String CLIENT_ENABLED
      Enables observations of gRPC client calls. Defaults to true.
      See Also:
    • ORDER

      public static final int ORDER
      The order of the observation interceptors: ahead of interceptors with the default order, so that calls they reject or fail are observed too.
      See Also:
  • Constructor Details

    • GrpcObservationFactory

      public GrpcObservationFactory()
  • Method Details

    • grpcServerObservationInterceptor

      @Singleton @Named("grpc-server-observation") @Requires(property="micrometer.observation.grpc.server.enabled", notEquals="false", defaultValue="true") protected io.grpc.ServerInterceptor grpcServerObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcServerObservationConvention convention)
      Creates the server observation interceptor.
      Parameters:
      registry - The observation registry
      convention - A custom observation convention, if one is declared as a bean
      Returns:
      The interceptor
    • grpcClientObservationInterceptor

      @Singleton @Named("grpc-client-observation") @Requires(property="micrometer.observation.grpc.client.enabled", notEquals="false", defaultValue="true") protected io.grpc.ClientInterceptor grpcClientObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcClientObservationConvention convention)
      Creates the client observation interceptor.
      Parameters:
      registry - The observation registry
      convention - A custom observation convention, if one is declared as a bean
      Returns:
      The interceptor