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
FieldsModifier and TypeFieldDescriptionstatic final StringEnables observations of gRPC client calls.static final intThe order of the observation interceptors: ahead of interceptors with the default order, so that calls they reject or fail are observed too.static final StringEnables observations of gRPC server calls. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected io.grpc.ClientInterceptorgrpcClientObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcClientObservationConvention convention) Creates the client observation interceptor.protected io.grpc.ServerInterceptorgrpcServerObservationInterceptor(io.micrometer.observation.ObservationRegistry registry, @Nullable io.micrometer.core.instrument.binder.grpc.GrpcServerObservationConvention convention) Creates the server observation interceptor.
-
Field Details
-
SERVER_ENABLED
Enables observations of gRPC server calls. Defaults totrue.- See Also:
-
CLIENT_ENABLED
Enables observations of gRPC client calls. Defaults totrue.- See Also:
-
ORDER
public static final int ORDERThe 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 registryconvention- 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 registryconvention- A custom observation convention, if one is declared as a bean- Returns:
- The interceptor
-