public final class MetricsSupport extends java.lang.Object implements Service
By defaults cretes 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(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());
| Modifier and Type | Class and Description |
|---|---|
static class |
MetricsSupport.Builder
A fluent API builder to build instances of
MetricsSupport. |
| Modifier and Type | Method and Description |
|---|---|
static MetricsSupport.Builder |
builder()
Create a new builder to construct an instance.
|
static MetricsSupport |
create()
Create an instance to be registered with Web Server with all defaults.
|
static MetricsSupport |
create(Config config)
Create an instance to be registered with Web Server maybe overriding default values with
configured values.
|
static java.lang.String |
toPrometheusData(Metric metric)
Returns the Prometheus data for the specified
Metric. |
void |
update(Routing.Rules rules)
Updates
Routing.Rules with handlers representing this service. |
public static MetricsSupport create()
public static MetricsSupport create(Config config)
config - Config instance to use to (maybe) override configuration of this component. See class javadoc for supported
configuration keys.public static MetricsSupport.Builder builder()
public static java.lang.String toPrometheusData(Metric metric)
Metric.
Not every Metric supports conversion to Prometheus data. This
method checks the metric first before performing the conversion,
throwing an IllegalArgumentException if the metric cannot be
converted.
metric - the Metric to convert to Prometheus formatString containing the Prometheus datapublic void update(Routing.Rules rules)
ServiceRouting.Rules with handlers representing this service.Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.