Package io.vertx.micrometer
Class MicrometerMetricsOptions
- java.lang.Object
-
- io.vertx.core.metrics.MetricsOptions
-
- io.vertx.micrometer.MicrometerMetricsOptions
-
public class MicrometerMetricsOptions extends MetricsOptions
Vert.x micrometer configuration.It is required to set either
influxDbOptions
,prometheusOptions
orjmxMetricsOptions
(or, programmatically,micrometerRegistry
) in order to actually report metrics.- Author:
- Joel Takvorian
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_JVM_METRICS_ENABLED
Whether JVM metrics should be collected by default = false.static List<Label>
DEFAULT_LABELS
Default label match for public http server: exclude remote labelstatic boolean
DEFAULT_METER_CACHED_ENABLED
Whether a meter cache should be enabled by default = true.static MetricsNaming
DEFAULT_METRICS_NAMING
Default metrics naming = Vert.x 4 namingstatic boolean
DEFAULT_NETTY_METRICS_ENABLED
Whether Netty metrics should be collected by default = false.static String
DEFAULT_REGISTRY_NAME
Default registry name is 'default'-
Fields inherited from class io.vertx.core.metrics.MetricsOptions
DEFAULT_METRICS_ENABLED
-
-
Constructor Summary
Constructors Constructor Description MicrometerMetricsOptions()
Creates default options for Micrometer metrics.MicrometerMetricsOptions(JsonObject json)
Creates new options object for Micrometer metrics fromjson
input.MicrometerMetricsOptions(MicrometerMetricsOptions other)
Creates new options object for Micrometer metrics, which is a copy ofother
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MicrometerMetricsOptions
addDisabledMetricsCategory(MetricsDomain metricsDomain)
Set metric that will not be registered.MicrometerMetricsOptions
addDisabledMetricsCategory(String category)
Set metric that will not be registered.MicrometerMetricsOptions
addLabelMatch(Match match)
Add a rule for label matching.MicrometerMetricsOptions
addLabels(Label... labels)
Add a labels to enable.java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>>
getClientRequestTagsProvider()
Set<String>
getDisabledMetricsCategories()
VertxInfluxDbOptions
getInfluxDbOptions()
Get the specific options for InfluxDB reporting.VertxJmxMetricsOptions
getJmxMetricsOptions()
Get the specific options for JMX reporting.List<Match>
getLabelMatches()
Set<Label>
getLabels()
MetricsNaming
getMetricsNaming()
MetricsNaming
is a structure that holds names of all metrics, each one can be changed individually.VertxPrometheusOptions
getPrometheusOptions()
Get the specific options for Prometheus reporting.String
getRegistryName()
Get the metrics registry name set in these optionsjava.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>>
getRequestsTagsProvider()
Deprecated.usegetServerRequestTagsProvider
insteadjava.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>>
getServerRequestTagsProvider()
boolean
isJvmMetricsEnabled()
boolean
isMeterCacheEnabled()
boolean
isMetricsCategoryDisabled(MetricsDomain metricsDomain)
Is the given metrics category disabled?boolean
isMetricsCategoryDisabled(String category)
Is the given metrics category disabled?boolean
isNettyMetricsEnabled()
MicrometerMetricsOptions
setClientRequestTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> clientRequestTagsProvider)
Sets a custom tags provider for HTTP client requests.MicrometerMetricsOptions
setDisabledMetricsCategories(Set<String> disabledMetricsCategories)
Sets metrics types that are disabled.MicrometerMetricsOptions
setEnabled(boolean enable)
Set whether metrics will be enabled on the Vert.x instance.MicrometerMetricsOptions
setInfluxDbOptions(VertxInfluxDbOptions influxDbOptions)
Set InfluxDB options.MicrometerMetricsOptions
setJmxMetricsOptions(VertxJmxMetricsOptions jmxMetricsOptions)
Set JMX metrics options.MicrometerMetricsOptions
setJvmMetricsEnabled(boolean jvmMetricsEnabled)
Whether JVM metrics should be collected.MicrometerMetricsOptions
setLabelMatches(List<Match> matches)
Set a list of rules for label matching.MicrometerMetricsOptions
setLabels(Set<Label> labels)
Sets enabled labels.MicrometerMetricsOptions
setMeterCacheEnabled(boolean meterCacheEnabled)
Whether a meter cache should be enabled.MicrometerMetricsOptions
setMetricsNaming(MetricsNaming metricsNaming)
MetricsNaming
is a structure that holds names of all metrics, each one can be changed individually.MicrometerMetricsOptions
setNettyMetricsEnabled(boolean nettyMetricsEnabled)
Whether Netty metrics should be collected.MicrometerMetricsOptions
setPrometheusOptions(VertxPrometheusOptions prometheusOptions)
Set Prometheus options.MicrometerMetricsOptions
setRegistryName(String registryName)
Set a name for the metrics registry, so that a new registry will be created and associated with this name.MicrometerMetricsOptions
setRequestsTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> serverRequestTagsProvider)
Deprecated.usesetServerRequestTagsProvider
insteadMicrometerMetricsOptions
setServerRequestTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> serverRequestTagsProvider)
Sets a custom tags provider for HTTP server requests.JsonObject
toJson()
-
Methods inherited from class io.vertx.core.metrics.MetricsOptions
isEnabled, toString
-
-
-
-
Field Detail
-
DEFAULT_REGISTRY_NAME
public static final String DEFAULT_REGISTRY_NAME
Default registry name is 'default'- See Also:
- Constant Field Values
-
DEFAULT_LABELS
public static final List<Label> DEFAULT_LABELS
Default label match for public http server: exclude remote label
-
DEFAULT_JVM_METRICS_ENABLED
public static final boolean DEFAULT_JVM_METRICS_ENABLED
Whether JVM metrics should be collected by default = false.- See Also:
- Constant Field Values
-
DEFAULT_NETTY_METRICS_ENABLED
public static final boolean DEFAULT_NETTY_METRICS_ENABLED
Whether Netty metrics should be collected by default = false.- See Also:
- Constant Field Values
-
DEFAULT_METRICS_NAMING
public static final MetricsNaming DEFAULT_METRICS_NAMING
Default metrics naming = Vert.x 4 naming
-
DEFAULT_METER_CACHED_ENABLED
public static final boolean DEFAULT_METER_CACHED_ENABLED
Whether a meter cache should be enabled by default = true.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MicrometerMetricsOptions
public MicrometerMetricsOptions()
Creates default options for Micrometer metrics.
-
MicrometerMetricsOptions
public MicrometerMetricsOptions(MicrometerMetricsOptions other)
Creates new options object for Micrometer metrics, which is a copy ofother
.
-
MicrometerMetricsOptions
public MicrometerMetricsOptions(JsonObject json)
Creates new options object for Micrometer metrics fromjson
input.
-
-
Method Detail
-
toJson
public JsonObject toJson()
- Overrides:
toJson
in classMetricsOptions
- Returns:
- a JSON representation of these options
-
setEnabled
public MicrometerMetricsOptions setEnabled(boolean enable)
Set whether metrics will be enabled on the Vert.x instance. Metrics are not enabled by default.- Overrides:
setEnabled
in classMetricsOptions
- Parameters:
enable
- true if metrics enabled, or false if not.- Returns:
- a reference to this, so the API can be used fluently
-
getDisabledMetricsCategories
public Set<String> getDisabledMetricsCategories()
- Returns:
- the disabled metrics types.
-
setDisabledMetricsCategories
public MicrometerMetricsOptions setDisabledMetricsCategories(Set<String> disabledMetricsCategories)
Sets metrics types that are disabled.- Parameters:
disabledMetricsCategories
- to specify the set of metrics types to be disabled.- Returns:
- a reference to this, so that the API can be used fluently
-
addDisabledMetricsCategory
public MicrometerMetricsOptions addDisabledMetricsCategory(MetricsDomain metricsDomain)
Set metric that will not be registered. Schedulers will check the setdisabledMetricsCategories
when registering metrics suppliers- Parameters:
metricsDomain
- the type of metrics- Returns:
- a reference to this, so that the API can be used fluently
-
addDisabledMetricsCategory
public MicrometerMetricsOptions addDisabledMetricsCategory(String category)
Set metric that will not be registered. Schedulers will check the setdisabledMetricsCategories
when registering metrics suppliers- Parameters:
category
- the type of metrics- Returns:
- a reference to this, so that the API can be used fluently
-
isMetricsCategoryDisabled
public boolean isMetricsCategoryDisabled(MetricsDomain metricsDomain)
Is the given metrics category disabled?- Returns:
true
if it is disabled
-
isMetricsCategoryDisabled
public boolean isMetricsCategoryDisabled(String category)
Is the given metrics category disabled?- Returns:
true
if it is disabled
-
getRegistryName
public String getRegistryName()
Get the metrics registry name set in these options
-
setRegistryName
public MicrometerMetricsOptions setRegistryName(String registryName)
Set a name for the metrics registry, so that a new registry will be created and associated with this name. IfregistryName
is not provided (or null), a default registry will be used. If the same name is given to several Vert.x instances (within the same JVM), they will share the same registry.- Parameters:
registryName
- a name to uniquely identify this registry
-
setLabels
public MicrometerMetricsOptions setLabels(Set<Label> labels)
Sets enabled labels. These labels can be fine-tuned later on using Micrometer's Meter filters (see http://micrometer.io/docs/concepts#_meter_filters)- Parameters:
labels
- the set of enabled labels - this set will replace any previously enabled labels, including the default ones- Returns:
- a reference to this, so that the API can be used fluently
-
addLabels
public MicrometerMetricsOptions addLabels(Label... labels)
Add a labels to enable. These labels can be fine-tuned later on using Micrometer's Meter filters (see http://micrometer.io/docs/concepts#_meter_filters)- Parameters:
labels
- the labels to enable- Returns:
- a reference to this, so that the API can be used fluently
-
setLabelMatches
public MicrometerMetricsOptions setLabelMatches(List<Match> matches)
Set a list of rules for label matching.- Parameters:
matches
- the new list of rules- Returns:
- a reference to this, so the API can be used fluently
-
addLabelMatch
public MicrometerMetricsOptions addLabelMatch(Match match)
Add a rule for label matching.- Parameters:
match
- the label match- Returns:
- a reference to this, so the API can be used fluently
-
getInfluxDbOptions
public VertxInfluxDbOptions getInfluxDbOptions()
Get the specific options for InfluxDB reporting.
-
setInfluxDbOptions
public MicrometerMetricsOptions setInfluxDbOptions(VertxInfluxDbOptions influxDbOptions)
Set InfluxDB options. Setting a registry backend option is mandatory in order to effectively report metrics.- Parameters:
influxDbOptions
- backend options for InfluxDB
-
getPrometheusOptions
public VertxPrometheusOptions getPrometheusOptions()
Get the specific options for Prometheus reporting.
-
setPrometheusOptions
public MicrometerMetricsOptions setPrometheusOptions(VertxPrometheusOptions prometheusOptions)
Set Prometheus options. Setting a registry backend option is mandatory in order to effectively report metrics.- Parameters:
prometheusOptions
- backend options for Prometheus
-
getJmxMetricsOptions
public VertxJmxMetricsOptions getJmxMetricsOptions()
Get the specific options for JMX reporting.
-
setJmxMetricsOptions
public MicrometerMetricsOptions setJmxMetricsOptions(VertxJmxMetricsOptions jmxMetricsOptions)
Set JMX metrics options. Setting a registry backend option is mandatory in order to effectively report metrics.- Parameters:
jmxMetricsOptions
- backend options for JMX reporting
-
isJvmMetricsEnabled
public boolean isJvmMetricsEnabled()
- Returns:
true
if JVM metrics should be collected,false
otherwise
-
setJvmMetricsEnabled
public MicrometerMetricsOptions setJvmMetricsEnabled(boolean jvmMetricsEnabled)
Whether JVM metrics should be collected. Defaults tofalse
.- Parameters:
jvmMetricsEnabled
-true
to collect JVM metrics,false
otherwise. Defaults tofalse
.- Returns:
- a reference to this, so the API can be used fluently
-
isNettyMetricsEnabled
public boolean isNettyMetricsEnabled()
- Returns:
true
if Netty metrics should be collected,false
otherwise
-
setNettyMetricsEnabled
public MicrometerMetricsOptions setNettyMetricsEnabled(boolean nettyMetricsEnabled)
Whether Netty metrics should be collected. Defaults tofalse
.- Parameters:
nettyMetricsEnabled
-true
to collect Netty metrics,false
otherwise. Defaults tofalse
.- Returns:
- a reference to this, so the API can be used fluently
-
getMetricsNaming
public MetricsNaming getMetricsNaming()
MetricsNaming
is a structure that holds names of all metrics, each one can be changed individually.- Returns:
- the configured
MetricsNaming
object (defaults to Vert.x names).
-
setMetricsNaming
public MicrometerMetricsOptions setMetricsNaming(MetricsNaming metricsNaming)
MetricsNaming
is a structure that holds names of all metrics, each one can be changed individually. For instance, to retrieve compatibility with the names used in Vert.x 3.x, usesetMetricsNaming(MetricsNaming.v3Names())
- Parameters:
metricsNaming
- aMetricsNaming
object.- Returns:
- a reference to this, so the API can be used fluently
-
getRequestsTagsProvider
@Deprecated public java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> getRequestsTagsProvider()
Deprecated.usegetServerRequestTagsProvider
instead- Returns:
- an optional custom tags provider for HTTP server requests
-
setRequestsTagsProvider
@Deprecated public MicrometerMetricsOptions setRequestsTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> serverRequestTagsProvider)
Deprecated.usesetServerRequestTagsProvider
insteadSets a custom tags provider for HTTP server requests. Allows to generate custom tags for everyHttpRequest
object processed through the metrics SPI.- Parameters:
serverRequestTagsProvider
- an object implementing theCustomTagsProvider
interface forHttpRequest
.- Returns:
- a reference to this, so that the API can be used fluently
-
getServerRequestTagsProvider
public java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> getServerRequestTagsProvider()
- Returns:
- an optional custom tags provider for HTTP server requests
-
setServerRequestTagsProvider
public MicrometerMetricsOptions setServerRequestTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> serverRequestTagsProvider)
Sets a custom tags provider for HTTP server requests. Allows to generate custom tags for everyHttpRequest
object processed through the metrics SPI.- Parameters:
serverRequestTagsProvider
- an object that returns an iterable ofTag
for aHttpRequest
.- Returns:
- a reference to this, so that the API can be used fluently
-
getClientRequestTagsProvider
public java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> getClientRequestTagsProvider()
- Returns:
- an optional custom tags provider for HTTP client requests
-
setClientRequestTagsProvider
public MicrometerMetricsOptions setClientRequestTagsProvider(java.util.function.Function<HttpRequest,Iterable<io.micrometer.core.instrument.Tag>> clientRequestTagsProvider)
Sets a custom tags provider for HTTP client requests. Allows to generate custom tags for everyHttpRequest
object processed through the metrics SPI.- Parameters:
clientRequestTagsProvider
- an object that returns an iterable ofTag
for aHttpRequest
.- Returns:
- a reference to this, so that the API can be used fluently
-
isMeterCacheEnabled
public boolean isMeterCacheEnabled()
- Returns:
true
if a meter cache should be enabled,false
otherwise
-
setMeterCacheEnabled
public MicrometerMetricsOptions setMeterCacheEnabled(boolean meterCacheEnabled)
Whether a meter cache should be enabled. Defaults totrue
.- Parameters:
meterCacheEnabled
-true
to enable a meter cache,false
otherwise. Defaults totrue
.- Returns:
- a reference to this, so the API can be used fluently
-
-