-
- All Superinterfaces:
RestServiceSupport
,Service
- All Known Implementing Classes:
MetricsSupport
,MinimalMetricsSupport
public interface MetricsSupport extends RestServiceSupport, Service
Behavior for supporting metrics for the Helidon Web Server.By default,
MetricsSupport
creates the/metrics
endpoint with three sub-paths:application
,vendor
, andbase
.To register these endpoints with the web server:
Routing.builder() .register(MetricsSupport.create())
This class supports finer-grained settings using
MetricsSettings
andRestServiceSettings
and Helidon Config viacreate(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 Classes Modifier and Type Interface Description static interface
MetricsSupport.Builder<T extends MetricsSupport>
Builder forMetricsSupport
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static 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
create(Config config)
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
defaultedMetricsRestServiceSettingsBuilder()
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 Detail
-
create
static MetricsSupport 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 and REST service settings
-
create
static MetricsSupport create(MetricsSettings metricsSettings)
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
static MetricsSupport create(Config config)
Creates a newMetricsSupport
instance using the specified configuration.- Parameters:
config
- configuration to use- Returns:
- new metrics support instance using the provided configuration
-
builder
static MetricsSupport.Builder<?> builder()
Returns a builder for the highest-priorityMetricsSupport
implementation.- Returns:
- builder for
MetricsSupport
-
defaultedMetricsRestServiceSettingsBuilder
static RestServiceSettings.Builder defaultedMetricsRestServiceSettingsBuilder()
Prepares aRestServiceSettings.Builder
instance for metrics with the default settings.- Returns:
- the prepared builder
-
prepareMetricsEndpoints
void prepareMetricsEndpoints(String endpointContext, Routing.Rules serviceEndpointRoutingRules)
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
void configureVendorMetrics(String routingName, Routing.Rules routingRules)
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
void update(Routing.Rules rules)
Description copied from interface:Service
UpdatesRouting.Rules
withhandlers
representing this service.
-
-