public abstract class AbstractMetricCollectingInterceptor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractMetricCollectingInterceptor.MetricSet
Container for all metrics of a certain call.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.function.UnaryOperator<io.micrometer.core.instrument.Counter.Builder> |
counterCustomizer |
protected io.grpc.Status.Code[] |
eagerInitializedCodes |
protected io.micrometer.core.instrument.MeterRegistry |
registry |
protected java.util.function.UnaryOperator<io.micrometer.core.instrument.Timer.Builder> |
timerCustomizer |
Constructor and Description |
---|
AbstractMetricCollectingInterceptor(io.micrometer.core.instrument.MeterRegistry registry)
Creates a new gRPC interceptor that will collect metrics into the given
MeterRegistry . |
AbstractMetricCollectingInterceptor(io.micrometer.core.instrument.MeterRegistry registry,
java.util.function.UnaryOperator<io.micrometer.core.instrument.Counter.Builder> counterCustomizer,
java.util.function.UnaryOperator<io.micrometer.core.instrument.Timer.Builder> timerCustomizer,
io.grpc.Status.Code... eagerInitializedCodes)
Creates a new gRPC interceptor that will collect metrics into the given
MeterRegistry and uses the given
customizer to configure the Counter s and Timer s. |
Modifier and Type | Method and Description |
---|---|
protected java.util.function.Function<io.grpc.Status.Code,io.micrometer.core.instrument.Timer> |
asTimerFunction(java.util.function.Supplier<io.micrometer.core.instrument.Timer.Builder> timerTemplate)
Creates a new timer function using the given template.
|
protected AbstractMetricCollectingInterceptor.MetricSet |
metricsFor(io.grpc.MethodDescriptor<?,?> method)
Gets or creates a
AbstractMetricCollectingInterceptor.MetricSet for the given gRPC method. |
protected AbstractMetricCollectingInterceptor.MetricSet |
newMetricsFor(io.grpc.MethodDescriptor<?,?> method)
Creates a
AbstractMetricCollectingInterceptor.MetricSet for the given gRPC method. |
protected abstract io.micrometer.core.instrument.Counter |
newRequestCounterFor(io.grpc.MethodDescriptor<?,?> method)
Creates a new request counter for the given method.
|
protected abstract io.micrometer.core.instrument.Counter |
newResponseCounterFor(io.grpc.MethodDescriptor<?,?> method)
Creates a new response counter for the given method.
|
protected abstract java.util.function.Function<io.grpc.Status.Code,io.micrometer.core.instrument.Timer> |
newTimerFunction(io.grpc.MethodDescriptor<?,?> method)
Creates a new timer for a given code for the given method.
|
void |
preregisterMethod(io.grpc.MethodDescriptor<?,?> method)
Pre-registers the given method.
|
void |
preregisterService(io.grpc.ServiceDescriptor service)
Pre-registers the all methods provided by the given service.
|
protected final io.micrometer.core.instrument.MeterRegistry registry
protected final java.util.function.UnaryOperator<io.micrometer.core.instrument.Counter.Builder> counterCustomizer
protected final java.util.function.UnaryOperator<io.micrometer.core.instrument.Timer.Builder> timerCustomizer
protected final io.grpc.Status.Code[] eagerInitializedCodes
public AbstractMetricCollectingInterceptor(io.micrometer.core.instrument.MeterRegistry registry)
MeterRegistry
. This method won't
use any customizers and will only initialize the OK
status.registry
- The registry to use.public AbstractMetricCollectingInterceptor(io.micrometer.core.instrument.MeterRegistry registry, java.util.function.UnaryOperator<io.micrometer.core.instrument.Counter.Builder> counterCustomizer, java.util.function.UnaryOperator<io.micrometer.core.instrument.Timer.Builder> timerCustomizer, io.grpc.Status.Code... eagerInitializedCodes)
MeterRegistry
and uses the given
customizer to configure the Counter
s and Timer
s.registry
- The registry to use.counterCustomizer
- The unary function that can be used to customize the created counters.timerCustomizer
- The unary function that can be used to customize the created timers.eagerInitializedCodes
- The status codes that should be eager initialized.public void preregisterService(io.grpc.ServiceDescriptor service)
service
- The service to initialize the meters for.preregisterMethod(MethodDescriptor)
public void preregisterMethod(io.grpc.MethodDescriptor<?,?> method)
method
- The method to initialize the meters for.protected final AbstractMetricCollectingInterceptor.MetricSet metricsFor(io.grpc.MethodDescriptor<?,?> method)
AbstractMetricCollectingInterceptor.MetricSet
for the given gRPC method. This will initialize all default counters and
timers for that method.method
- The method to get the metric set for.newMetricsFor(MethodDescriptor)
protected AbstractMetricCollectingInterceptor.MetricSet newMetricsFor(io.grpc.MethodDescriptor<?,?> method)
AbstractMetricCollectingInterceptor.MetricSet
for the given gRPC method. This will initialize all default counters and timers for
that method.method
- The method to get the metric set for.protected abstract io.micrometer.core.instrument.Counter newRequestCounterFor(io.grpc.MethodDescriptor<?,?> method)
method
- The method to create the counter for.protected abstract io.micrometer.core.instrument.Counter newResponseCounterFor(io.grpc.MethodDescriptor<?,?> method)
method
- The method to create the counter for.protected java.util.function.Function<io.grpc.Status.Code,io.micrometer.core.instrument.Timer> asTimerFunction(java.util.function.Supplier<io.micrometer.core.instrument.Timer.Builder> timerTemplate)
timerTemplate
- The template to create the instances from.protected abstract java.util.function.Function<io.grpc.Status.Code,io.micrometer.core.instrument.Timer> newTimerFunction(io.grpc.MethodDescriptor<?,?> method)
method
- The method to create the timer for.