- java.lang.Object
-
- io.helidon.grpc.metrics.GrpcMetrics
-
- All Implemented Interfaces:
io.grpc.ServerInterceptor
,MethodDescriptor.Configurer
,ServiceDescriptor.Configurer
@Priority(1002) public class GrpcMetrics extends Object implements io.grpc.ServerInterceptor, ServiceDescriptor.Configurer, MethodDescriptor.Configurer
AServerInterceptor
that enables capturing of gRPC call metrics.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GrpcMetrics.NamingFunction
Implemented by classes that can create a metric name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GrpcMetrics
concurrentGauge()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.void
configure(MethodDescriptor.Rules rules)
Apply extra configuration to aMethodDescriptor.Rules
.void
configure(ServiceDescriptor.Rules rules)
Apply extra configuration to aServiceDescriptor.Rules
.static GrpcMetrics
counted()
A static factory method to create aGrpcMetrics
instance to count gRPC method calls.GrpcMetrics
description(String description)
Set the description to apply to the metric.GrpcMetrics
displayName(String displayName)
Set the display name to apply to the metric.boolean
equals(Object o)
int
hashCode()
static GrpcMetrics
histogram()
A static factory method to create aGrpcMetrics
instance to create a histogram of gRPC method calls.<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT>interceptCall(io.grpc.ServerCall<ReqT,RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT,RespT> next)
static GrpcMetrics
metered()
A static factory method to create aGrpcMetrics
instance to meter gRPC method calls.MetricType
metricType()
Obtain theMetricType
.GrpcMetrics
nameFunction(GrpcMetrics.NamingFunction function)
Set theGrpcMetrics.NamingFunction
to use to generate the metric name.GrpcMetrics
reusable(boolean reusable)
Set the reusability of the metric.static GrpcMetrics
simplyTimed()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.GrpcMetrics
tags(Map<String,String> tags)
Set the tags to apply to the metric.static GrpcMetrics
timed()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.GrpcMetrics
units(String units)
Set the units to apply to the metric.
-
-
-
Method Detail
-
configure
public void configure(MethodDescriptor.Rules rules)
Description copied from interface:MethodDescriptor.Configurer
Apply extra configuration to aMethodDescriptor.Rules
.- Specified by:
configure
in interfaceMethodDescriptor.Configurer
- Parameters:
rules
- theMethodDescriptor.Rules
to configure
-
configure
public void configure(ServiceDescriptor.Rules rules)
Description copied from interface:ServiceDescriptor.Configurer
Apply extra configuration to aServiceDescriptor.Rules
.- Specified by:
configure
in interfaceServiceDescriptor.Configurer
- Parameters:
rules
- theServiceDescriptor.Rules
to configure
-
tags
public GrpcMetrics tags(Map<String,String> tags)
Set the tags to apply to the metric.- Parameters:
tags
- the tags to apply to the metric- Returns:
- a
GrpcMetrics
interceptor - See Also:
Metadata
-
description
public GrpcMetrics description(String description)
Set the description to apply to the metric.- Parameters:
description
- the description to apply to the metric- Returns:
- a
GrpcMetrics
interceptor - See Also:
Metadata
-
displayName
public GrpcMetrics displayName(String displayName)
Set the display name to apply to the metric.- Parameters:
displayName
- the display name to apply to the metric- Returns:
- a
GrpcMetrics
interceptor - See Also:
Metadata
-
units
public GrpcMetrics units(String units)
Set the units to apply to the metric.- Parameters:
units
- the units to apply to the metric- Returns:
- a
GrpcMetrics
interceptor - See Also:
Metadata
-
reusable
public GrpcMetrics reusable(boolean reusable)
Set the reusability of the metric.- Parameters:
reusable
-true
if this metric may be reused- Returns:
- a
GrpcMetrics
interceptor - See Also:
Metadata
-
metricType
public MetricType metricType()
Obtain theMetricType
.- Returns:
- the
MetricType
-
nameFunction
public GrpcMetrics nameFunction(GrpcMetrics.NamingFunction function)
Set theGrpcMetrics.NamingFunction
to use to generate the metric name.The default name will be the
<service-name>.<method-name>
.- Parameters:
function
- the function to use to create the metric name- Returns:
- a
GrpcMetrics
interceptor
-
counted
public static GrpcMetrics counted()
A static factory method to create aGrpcMetrics
instance to count gRPC method calls.- Returns:
- a
GrpcMetrics
instance to capture call counts
-
metered
public static GrpcMetrics metered()
A static factory method to create aGrpcMetrics
instance to meter gRPC method calls.- Returns:
- a
GrpcMetrics
instance to meter gRPC calls
-
histogram
public static GrpcMetrics histogram()
A static factory method to create aGrpcMetrics
instance to create a histogram of gRPC method calls.- Returns:
- a
GrpcMetrics
instance to create a histogram of gRPC method calls
-
timed
public static GrpcMetrics timed()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.- Returns:
- a
GrpcMetrics
instance to time gRPC method calls
-
concurrentGauge
public static GrpcMetrics concurrentGauge()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.- Returns:
- a
GrpcMetrics
instance to time gRPC method calls
-
simplyTimed
public static GrpcMetrics simplyTimed()
A static factory method to create aGrpcMetrics
instance to time gRPC method calls.- Returns:
- a
GrpcMetrics
instance to time gRPC method calls
-
interceptCall
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT,RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT,RespT> next)
- Specified by:
interceptCall
in interfaceio.grpc.ServerInterceptor
-
-