All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.micrometer.MicrometerMetricsOptions Maven / Gradle / Ivy

/*
 * Copyright (c) 2011-2017 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */
package io.vertx.micrometer;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.metrics.MetricsOptions;
import io.vertx.core.spi.VertxMetricsFactory;
import io.vertx.core.spi.observability.HttpRequest;

import java.util.*;
import java.util.function.Function;

/**
 * Vert.x micrometer configuration.
 * 

* It is required to set either {@code influxDbOptions}, {@code prometheusOptions} or {@code jmxMetricsOptions} * (or, programmatically, {@code micrometerRegistry}) in order to actually report metrics. * * @author Joel Takvorian */ @DataObject(generateConverter = true, inheritConverter = true) public class MicrometerMetricsOptions extends MetricsOptions { /** * Default registry name is 'default' */ public static final String DEFAULT_REGISTRY_NAME = "default"; /** * Default label match for public http server: exclude remote label */ public static final List

    *
  • if there is already a MeterRegistry used in the application * that should be used by Vert.x as well.
  • *
  • to define some backend configuration that is not covered in this module * (example: reporting to non-covered backends such as New Relic)
  • *
  • to use Micrometer's CompositeRegistry
  • *
* * This setter is mutually exclusive with setInfluxDbOptions/setPrometheusOptions/setJmxMetricsOptions * and takes precedence over them. * * @param micrometerRegistry the registry to use * @return a reference to this, so the API can be used fluently */ public MicrometerMetricsOptions setMicrometerRegistry(MeterRegistry micrometerRegistry) { this.micrometerRegistry = micrometerRegistry; return this; } /** * Get the specific options for InfluxDB reporting. */ public VertxInfluxDbOptions getInfluxDbOptions() { return influxDbOptions; } /** * Set InfluxDB options. * Setting a registry backend option is mandatory in order to effectively report metrics. * @param influxDbOptions backend options for InfluxDB */ public MicrometerMetricsOptions setInfluxDbOptions(VertxInfluxDbOptions influxDbOptions) { this.influxDbOptions = influxDbOptions; return this; } /** * Get the specific options for Prometheus reporting. */ public VertxPrometheusOptions getPrometheusOptions() { return prometheusOptions; } /** * Set Prometheus options. * Setting a registry backend option is mandatory in order to effectively report metrics. * @param prometheusOptions backend options for Prometheus */ public MicrometerMetricsOptions setPrometheusOptions(VertxPrometheusOptions prometheusOptions) { this.prometheusOptions = prometheusOptions; return this; } /** * Get the specific options for JMX reporting. */ public VertxJmxMetricsOptions getJmxMetricsOptions() { return jmxMetricsOptions; } /** * Set JMX metrics options. * Setting a registry backend option is mandatory in order to effectively report metrics. * @param jmxMetricsOptions backend options for JMX reporting */ public MicrometerMetricsOptions setJmxMetricsOptions(VertxJmxMetricsOptions jmxMetricsOptions) { this.jmxMetricsOptions = jmxMetricsOptions; return this; } /** * @return true if JVM metrics should be collected, false otherwise */ public boolean isJvmMetricsEnabled() { return jvmMetricsEnabled; } /** * Whether JVM metrics should be collected. Defaults to {@code false}. * * @param jvmMetricsEnabled true to collect JVM metrics, false otherwise. Defaults to {@code false}. * @return a reference to this, so the API can be used fluently */ public MicrometerMetricsOptions setJvmMetricsEnabled(boolean jvmMetricsEnabled) { this.jvmMetricsEnabled = jvmMetricsEnabled; return this; } /** * {@code MetricsNaming} is a structure that holds names of all metrics, each one can be changed individually. * @return the configured {@code MetricsNaming} object (defaults to Vert.x names). */ public MetricsNaming getMetricsNaming() { return metricsNaming; } /** * {@code 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, use {@code setMetricsNaming(MetricsNaming.v3Names())} * * @param metricsNaming a {@code MetricsNaming} object. * @return a reference to this, so the API can be used fluently */ public MicrometerMetricsOptions setMetricsNaming(MetricsNaming metricsNaming) { this.metricsNaming = metricsNaming; return this; } /** * @return an optional custom tags provider for HTTP server requests * @deprecated use {@code getServerRequestTagsProvider} instead */ @GenIgnore @Deprecated public Function> getRequestsTagsProvider() { return this.getServerRequestTagsProvider(); } /** * Sets a custom tags provider for HTTP server requests. Allows to generate custom tags for every {@code HttpRequest} object processed through the metrics SPI. * * @param serverRequestTagsProvider an object implementing the {@code CustomTagsProvider} interface for {@code HttpRequest}. * @return a reference to this, so that the API can be used fluently * @deprecated use {@code setServerRequestTagsProvider} instead */ @GenIgnore @Deprecated public MicrometerMetricsOptions setRequestsTagsProvider(Function> serverRequestTagsProvider) { return this.setServerRequestTagsProvider(serverRequestTagsProvider); } /** * @return an optional custom tags provider for HTTP server requests */ @GenIgnore public Function> getServerRequestTagsProvider() { return serverRequestTagsProvider; } /** * Sets a custom tags provider for HTTP server requests. Allows to generate custom tags for every {@code HttpRequest} object processed through the metrics SPI. * * @param serverRequestTagsProvider an object that returns an iterable of {@code Tag} for a {@code HttpRequest}. * @return a reference to this, so that the API can be used fluently */ @GenIgnore public MicrometerMetricsOptions setServerRequestTagsProvider(Function> serverRequestTagsProvider) { this.serverRequestTagsProvider = serverRequestTagsProvider; return this; } /** * @return an optional custom tags provider for HTTP client requests */ @GenIgnore public Function> getClientRequestTagsProvider() { return clientRequestTagsProvider; } /** * Sets a custom tags provider for HTTP client requests. Allows to generate custom tags for every {@code HttpRequest} object processed through the metrics SPI. * * @param clientRequestTagsProvider an object that returns an iterable of {@code Tag} for a {@code HttpRequest}. * @return a reference to this, so that the API can be used fluently */ @GenIgnore public MicrometerMetricsOptions setClientRequestTagsProvider(Function> clientRequestTagsProvider) { this.clientRequestTagsProvider = clientRequestTagsProvider; return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy