- 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
Modifier and TypeInterfaceDescriptionstatic interface
MetricsSupport.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-priorityMetricsSupport
implementation.void
configureEndpoint
(Routing.Rules defaultRoutingRules, Routing.Rules serviceEndpointRoutingRules) Prepares the endpoint which the service exposes.void
configureVendorMetrics
(String routingName, Routing.Rules routingRules) Sets up vendor metrics routing using the specified routing name and routing builder.static MetricsSupport
create()
Creates a newMetricsSupport
instance using default metrics settings.static MetricsSupport
Creates a newMetricsSupport
instance using the specified configuration.static MetricsSupport
create
(MetricsSettings metricsSettings) Creates a newMetricsSupport
instance using the specified metrics settings and defaulted REST service settings.static MetricsSupport
create
(MetricsSettings metricsSettings, RestServiceSettings restServiceSettings) Creates a newMetricsSupport
instance using the specified metrics settings and REST service settings.static RestServiceSettings.Builder
Prepares aRestServiceSettings.Builder
instance for metrics with the default settings.void
prepareMetricsEndpoints
(String endpointContext, Routing.Rules serviceEndpointRoutingRules) Prepares the family of/metrics
endpoints.void
update
(Routing.Rules rules) UpdatesRouting.Rules
withhandlers
representing this service.
-
Method Details
-
create
Creates a newMetricsSupport
instance using default metrics settings.- Returns:
- new metrics support using default metrics settings
-
create
static MetricsSupport create(MetricsSettings metricsSettings, RestServiceSettings restServiceSettings) Creates a newMetricsSupport
instance 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 newMetricsSupport
instance 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 newMetricsSupport
instance 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-priorityMetricsSupport
implementation.- Returns:
- builder for
MetricsSupport
-
defaultedMetricsRestServiceSettingsBuilder
Prepares aRestServiceSettings.Builder
instance for metrics with the default settings.- Returns:
- the prepared builder
-
prepareMetricsEndpoints
Prepares the family of/metrics
endpoints.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:
configureEndpoint
in 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:Service
UpdatesRouting.Rules
withhandlers
representing this service.
-