Class MetricCollectingService
java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Service<HttpRequest,HttpResponse>>
com.linecorp.armeria.server.DecoratingService<HttpRequest,HttpResponse,HttpRequest,HttpResponse>
com.linecorp.armeria.server.SimpleDecoratingService<HttpRequest,HttpResponse>
com.linecorp.armeria.server.SimpleDecoratingHttpService
com.linecorp.armeria.server.metric.MetricCollectingService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,
HttpResponse>
Decorates an
HttpService
to collect metrics into MeterRegistry
.
Example:
serverBuilder.service(
"/service",
THttpService.of(handler)
.decorate(MetricCollectingService.newDecorator(
MeterIdPrefixFunction.ofDefault("myService"))));
It is generally recommended not to use a class or package name as a metric name, because otherwise seemingly harmless refactoring such as rename may break metric collection.
-
Method Summary
Modifier and TypeMethodDescriptionbuilder
(MeterIdPrefixFunction meterIdPrefixFunction) Returns a newly createdMetricCollectingServiceBuilder
.static Function
<? super HttpService, MetricCollectingService> newDecorator
(MeterIdPrefixFunction meterIdPrefixFunction) Returns a newHttpService
decorator that tracks request stats usingMeterRegistry
.serve
(ServiceRequestContext ctx, HttpRequest req) Serves an incomingRequest
.void
Invoked when this service has been added to aServer
with the specified configuration.Methods inherited from class com.linecorp.armeria.server.SimpleDecoratingHttpService
exchangeType, options
Methods inherited from class com.linecorp.armeria.server.DecoratingService
shouldCachePath
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAll
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.HttpService
decorate, decorate
Methods inherited from interface com.linecorp.armeria.server.Service
as, shouldCachePath, unwrap
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
newDecorator
public static Function<? super HttpService,MetricCollectingService> newDecorator(MeterIdPrefixFunction meterIdPrefixFunction) Returns a newHttpService
decorator that tracks request stats usingMeterRegistry
. -
builder
Returns a newly createdMetricCollectingServiceBuilder
. -
serve
Description copied from interface:Service
Serves an incomingRequest
. -
serviceAdded
Description copied from interface:Service
Invoked when this service has been added to aServer
with the specified configuration. Please note that this method can be invoked more than once if this service has been added more than once.- Specified by:
serviceAdded
in interfaceService<HttpRequest,
HttpResponse> - Overrides:
serviceAdded
in classDecoratingService<HttpRequest,
HttpResponse, HttpRequest, HttpResponse> - Throws:
Exception
-