public abstract class AbstractMetricCollectingInterceptor extends 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 UnaryOperator<Counter.Builder> |
counterCustomizer |
protected Status.Code[] |
eagerInitializedCodes |
protected MeterRegistry |
registry |
protected UnaryOperator<Timer.Builder> |
timerCustomizer |
Constructor and Description |
---|
AbstractMetricCollectingInterceptor(MeterRegistry registry)
Creates a new gRPC interceptor that will collect metrics into the given
MeterRegistry . |
AbstractMetricCollectingInterceptor(MeterRegistry registry,
UnaryOperator<Counter.Builder> counterCustomizer,
UnaryOperator<Timer.Builder> timerCustomizer,
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 Function<Status.Code,Timer> |
asTimerFunction(Supplier<Timer.Builder> timerTemplate)
Creates a new timer function using the given template.
|
protected AbstractMetricCollectingInterceptor.MetricSet |
metricsFor(MethodDescriptor<?,?> method)
Gets or creates a
AbstractMetricCollectingInterceptor.MetricSet for the given gRPC method. |
protected AbstractMetricCollectingInterceptor.MetricSet |
newMetricsFor(MethodDescriptor<?,?> method)
Creates a
AbstractMetricCollectingInterceptor.MetricSet for the given gRPC method. |
protected abstract Counter |
newRequestCounterFor(MethodDescriptor<?,?> method)
Creates a new request counter for the given method.
|
protected abstract Counter |
newResponseCounterFor(MethodDescriptor<?,?> method)
Creates a new response counter for the given method.
|
protected abstract Function<Status.Code,Timer> |
newTimerFunction(MethodDescriptor<?,?> method)
Creates a new timer for a given code for the given method.
|
void |
preregisterMethod(MethodDescriptor<?,?> method)
Pre-registers the given method.
|
void |
preregisterService(ServiceDescriptor service)
Pre-registers the all methods provided by the given service.
|
protected final MeterRegistry registry
protected final UnaryOperator<Counter.Builder> counterCustomizer
protected final UnaryOperator<Timer.Builder> timerCustomizer
protected final Status.Code[] eagerInitializedCodes
public AbstractMetricCollectingInterceptor(MeterRegistry registry)
MeterRegistry
. This method won't
use any customizers and will only initialize the OK
status.registry
- The registry to use.public AbstractMetricCollectingInterceptor(MeterRegistry registry, UnaryOperator<Counter.Builder> counterCustomizer, UnaryOperator<Timer.Builder> timerCustomizer, 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(ServiceDescriptor service)
service
- The service to initialize the meters for.preregisterMethod(MethodDescriptor)
public void preregisterMethod(MethodDescriptor<?,?> method)
method
- The method to initialize the meters for.protected final AbstractMetricCollectingInterceptor.MetricSet metricsFor(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(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 Counter newRequestCounterFor(MethodDescriptor<?,?> method)
method
- The method to create the counter for.protected abstract Counter newResponseCounterFor(MethodDescriptor<?,?> method)
method
- The method to create the counter for.protected Function<Status.Code,Timer> asTimerFunction(Supplier<Timer.Builder> timerTemplate)
timerTemplate
- The template to create the instances from.protected abstract Function<Status.Code,Timer> newTimerFunction(MethodDescriptor<?,?> method)
method
- The method to create the timer for.