java.lang.Object
io.helidon.nima.servicecommon.HelidonFeatureSupport
io.helidon.nima.observe.metrics.MetricsFeature
- All Implemented Interfaces:
FeatureSupport,HttpFeature,ServerLifecycle,Supplier<HttpFeature>
Support for metrics for Helidon Web Server.
By defaults creates the /metrics endpoint with three sub-paths: application, vendor and base.
To register with web server:
Routing.builder()
.register(MetricsSupport.create())
This class supports finer grained configuration using Helidon Config:
create(io.helidon.config.Config). The following configuration parameters can be used:
| key | default value | description |
|---|---|---|
| helidon.metrics.context | /metrics | Context root under which the rest endpoints are available |
| helidon.metrics.base.${metricName}.enabled | true | Can control which base metrics are exposed, set to false to disable a base metric |
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 TypeClassDescriptionstatic final classA fluent API builder to build instances ofMetricsFeature. -
Method Summary
Modifier and TypeMethodDescriptionvoidAfter server stop.voidBefore server start.static MetricsFeature.Builderbuilder()Create a new builder to construct an instance.voidConfigure Helidon specific metrics.static MetricsFeaturecreate()Create an instance to be registered with Web Server with all defaults.static MetricsFeatureCreate an instance to be registered with Web Server maybe overriding default values with configured values.protected voidpostSetup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) This can be used to register services, filters etc.service()If this feature is represented by a service, return it here, to simplify implementation.Methods inherited from class io.helidon.nima.servicecommon.HelidonFeatureSupport
configuredContext, context, context, enabled, logger, setupMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.nima.servicecommon.FeatureSupport
setupMethods inherited from interface io.helidon.nima.webserver.http.HttpFeature
get
-
Method Details
-
create
Create an instance to be registered with Web Server with all defaults.- Returns:
- a new instance built with default values (for context, base metrics enabled)
-
create
Create an instance to be registered with Web Server maybe overriding default values with configured values.- Parameters:
config- Config instance to use to (maybe) override configuration of this component. See class javadoc for supported configuration keys.- Returns:
- a new instance configured withe config provided
-
builder
Create a new builder to construct an instance.- Returns:
- a new builder instance
-
service
Description copied from interface:FeatureSupportIf this feature is represented by a service, return it here, to simplify implementation. Otherwise you will need to implementFeatureSupport.setup(HttpRouting.Builder, HttpRouting.Builder).- Returns:
- service if implemented
-
configureVendorMetrics
Configure Helidon specific metrics.- Parameters:
rules- rules to use
-
beforeStart
public void beforeStart()Description copied from interface:ServerLifecycleBefore server start. -
afterStop
public void afterStop()Description copied from interface:ServerLifecycleAfter server stop. -
postSetup
Description copied from class:HelidonFeatureSupportThis can be used to register services, filters etc. on either the default rules (usually the main routing of the web server) and the feature routing (may be the same instance). IfFeatureSupport.service()provides an instance, that instance will be correctly registered with the context root on feature routing.- Overrides:
postSetupin classHelidonFeatureSupport- Parameters:
defaultRouting- defaultHttpRulesto be updatedfeatureRouting- actual rules (if different from the default ones) to be updated for the service endpoint
-