public final class MetricCollectingService extends SimpleDecoratingHttpService
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.
| Modifier and Type | Method and Description |
|---|---|
static Function<? super HttpService,MetricCollectingService> |
newDecorator(MeterIdPrefixFunction meterIdPrefixFunction)
Returns a new
HttpService decorator that tracks request stats using MeterRegistry. |
HttpResponse |
serve(ServiceRequestContext ctx,
HttpRequest req)
Serves an incoming
Request. |
serviceAdded, shouldCachePathas, delegate, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdecorate, decorateas, decorate, serviceAdded, shouldCachePathpublic static Function<? super HttpService,MetricCollectingService> newDecorator(MeterIdPrefixFunction meterIdPrefixFunction)
HttpService decorator that tracks request stats using MeterRegistry.public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception
ServiceRequest.Copyright © 2020 LeanCloud. All rights reserved.