- All Superinterfaces:
RestServiceSupport,Service
- All Known Implementing Classes:
MetricsSupport,MinimalMetricsSupport
Behavior for supporting metrics for the Helidon Web Server.
By default, MetricsSupport creates the /metrics endpoint with three sub-paths: application,
vendor, and base.
To register these endpoints with the web server:
Routing.builder()
.register(MetricsSupport.create())
This class supports finer-grained settings using MetricsSettings and
RestServiceSettings and Helidon Config via
create(io.helidon.metrics.api.MetricsSettings, io.helidon.servicecommon.rest.RestServiceSettings).
During request handling the application metrics registry is then available as follows:
req.context().get(MetricRegistry.class).ifPresent(reg -> reg.counter("myCounter").inc());
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceMetricsSupport.Builder<B extends MetricsSupport.Builder<B,T>, T extends MetricsSupport> Builder forMetricsSupport. -
Method Summary
Modifier and TypeMethodDescriptionstatic MetricsSupport.Builder<?,?> builder()Returns a builder for the highest-priorityMetricsSupportimplementation.voidconfigureEndpoint(Routing.Rules defaultRoutingRules, Routing.Rules serviceEndpointRoutingRules) Prepares the endpoint which the service exposes.voidconfigureVendorMetrics(String routingName, Routing.Rules routingRules) Sets up vendor metrics routing using the specified routing name and routing builder.static MetricsSupportcreate()Creates a newMetricsSupportinstance using default metrics settings.static MetricsSupportCreates a newMetricsSupportinstance using the specified configuration.static MetricsSupportcreate(MetricsSettings metricsSettings) Creates a newMetricsSupportinstance using the specified metrics settings and defaulted REST service settings.static MetricsSupportcreate(MetricsSettings metricsSettings, RestServiceSettings restServiceSettings) Creates a newMetricsSupportinstance using the specified metrics settings and REST service settings.static RestServiceSettings.BuilderPrepares aRestServiceSettings.Builderinstance for metrics with the default settings.voidprepareMetricsEndpoints(String endpointContext, Routing.Rules serviceEndpointRoutingRules) Prepares the family of/metricsendpoints.voidupdate(Routing.Rules rules) UpdatesRouting.Ruleswithhandlersrepresenting this service.
-
Method Details
-
create
Creates a newMetricsSupportinstance using default metrics settings.- Returns:
- new metrics support using default metrics settings
-
create
static MetricsSupport create(MetricsSettings metricsSettings, RestServiceSettings restServiceSettings) Creates a newMetricsSupportinstance using the specified metrics settings and REST service settings.- Parameters:
metricsSettings- metrics settings to use in initializing the metrics supportrestServiceSettings- REST service settings for the metrics endpoint- Returns:
- new metrics support using specified metrics settings and REST service settings
-
create
Creates a newMetricsSupportinstance using the specified metrics settings and defaulted REST service settings.- Parameters:
metricsSettings- metrics settings to use in initializing the metrics support- Returns:
- new metrics support using the specified metrics settings
-
create
Creates a newMetricsSupportinstance using the specified configuration.- Parameters:
config- configuration to use- Returns:
- new metrics support instance using the provided configuration
-
builder
Returns a builder for the highest-priorityMetricsSupportimplementation.- Returns:
- builder for
MetricsSupport
-
defaultedMetricsRestServiceSettingsBuilder
Prepares aRestServiceSettings.Builderinstance for metrics with the default settings.- Returns:
- the prepared builder
-
prepareMetricsEndpoints
Prepares the family of/metricsendpoints.By default, requests to the metrics endpoints trigger a 404 response with an explanatory message that metrics are disabled. Implementations of this interface can provide more informative endpoints.
- Parameters:
endpointContext- context (typically /metrics)serviceEndpointRoutingRules- routing rules to update with the disabled metrics endpoints
-
configureEndpoint
void configureEndpoint(Routing.Rules defaultRoutingRules, Routing.Rules serviceEndpointRoutingRules) Prepares the endpoint which the service exposes.- Specified by:
configureEndpointin interfaceRestServiceSupport- Parameters:
defaultRoutingRules- routing rules for the default routingserviceEndpointRoutingRules- routing rules (if different from default) for the service endpoint
-
configureVendorMetrics
Sets up vendor metrics routing using the specified routing name and routing builder.- Parameters:
routingName- routing name to use in setting up the vendor metricsroutingRules- routing rules to modify
-
update
Description copied from interface:ServiceUpdatesRouting.Ruleswithhandlersrepresenting this service.
-