Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/native-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
{
"category": "Observability",
"timeout": 130,
"test-modules": "smallrye-metrics, micrometer-mp-metrics, micrometer-prometheus, micrometer-prometheus-opentelemetry, logging-json, observability-lgtm, opentelemetry, opentelemetry-jdbc-instrumentation, opentelemetry-mongodb-client-instrumentation, opentelemetry-redis-instrumentation, micrometer-opentelemetry",
"test-modules": "smallrye-metrics, micrometer-mp-metrics, micrometer-prometheus, logging-json, observability-lgtm, opentelemetry, opentelemetry-jdbc-instrumentation, opentelemetry-mongodb-client-instrumentation, opentelemetry-redis-instrumentation, micrometer-opentelemetry",
"os-name": "ubuntu-latest"
},
{
Expand Down
16 changes: 15 additions & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<opentelemetry-instrumentation.version>2.10.0-alpha</opentelemetry-instrumentation.version>
<opentelemetry-semconv.version>1.29.0-alpha</opentelemetry-semconv.version>
<quarkus-http.version>5.3.5</quarkus-http.version>
<micrometer.version>1.15.0</micrometer.version><!-- keep in sync with prometheus-client and hdrhistogram: https://central.sonatype.com/artifact/io.micrometer/micrometer-core -->
<micrometer.version>1.14.7</micrometer.version><!-- keep in sync with hdrhistogram: https://central.sonatype.com/artifact/io.micrometer/micrometer-core -->
<hdrhistogram.version>2.2.2</hdrhistogram.version><!-- keep in sync with micrometer -->
<google-auth.version>0.22.0</google-auth.version>
<graphql-java.version>22.2</graphql-java.version> <!-- keep in sync with smallrye-graphql -->
Expand Down Expand Up @@ -215,6 +215,8 @@
<mutiny-zero.version>1.1.1</mutiny-zero.version>
<pulsar-client.version>3.3.0</pulsar-client.version>
<async-http-client.version>2.12.4</async-http-client.version>
<!-- keep in-sync, if possible, with Micrometer registry Prometheus -->
<prometheus.version>0.16.0</prometheus.version>
<!-- Dev UI -->
<importmap.version>1.0.11</importmap.version>
<webauthn4j.version>0.28.0.RELEASE</webauthn4j.version>
Expand Down Expand Up @@ -535,6 +537,18 @@
<scope>import</scope>
</dependency>

<!-- Prometheus -->
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_common</artifactId>
<version>${prometheus.version}</version>
</dependency>

<!-- Quarkus core -->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The JVM and HTTP server metrics are collected by Micrometer.
Next, are examples of the metrics collected by Micrometer and a comparison of what would be the `quarkus-micrometer-registry-prometheus` output vs the one on this bridge. A link to the equivalent OpenTelemetry Semantic Convention is also provided for reference and is not currently used in the bridge.

|===
|Micrometer Meter |Quarkus Micrometer Prometheus client v0.x output | This bridge OpenTelemetry output name | Related OpenTelemetry Semantic Convention (not applied)
|Micrometer Meter |Quarkus Micrometer Prometheus output | This bridge OpenTelemetry output name | Related OpenTelemetry Semantic Convention (not applied)

|Using the @Timed interceptor.
|
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/telemetry-micrometer-tutorial.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ You should find something like this:
----
# HELP http_server_requests_seconds
# TYPE http_server_requests_seconds summary
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 2
http_server_requests_seconds_count{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 2.0
http_server_requests_seconds_sum{method="GET",outcome="SUCCESS",status="200",uri="/example/prime/{number}"} 0.017385896
# HELP http_server_requests_seconds_max
# TYPE http_server_requests_seconds_max gauge
Expand Down
7 changes: 3 additions & 4 deletions docs/src/main/asciidoc/telemetry-micrometer.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ IMPORTANT: Micrometer is the recommended approach to metrics for Quarkus.
NOTE: By default, the metrics are exposed on the main HTTP server.
If you would like to surface metrics from a separate management port, see the <<management-interface,Managed interface>> section.

NOTE: `quarkus-micrometer` now uses the Prometheus client v1.x. For help migrating from the old client, please check the https://github.com/micrometer-metrics/micrometer/wiki/1.13-Migration-Guide[Prometheus Java client 0.x to 1.x upgrade] from Micrometer.

== Micrometer and monitoring system extensions

Quarkus Micrometer extensions are structured in the same way as the Micrometer project.
Expand All @@ -35,7 +33,7 @@ Other Quarkus and Quarkiverse extensions use the Quarkus Micrometer extension to
Quarkus extensions:

- micrometer
- micrometer-registry-prometheus (Prometheus client v1.x)
- micrometer-registry-prometheus

link:https://github.com/quarkiverse/quarkus-micrometer-registry[Quarkiverse extensions] (may be incomplete):

Expand Down Expand Up @@ -174,7 +172,7 @@ Micrometer applies naming conventions to convert registered meter names to match

Given the following declaration of a timer: `registry.timer("http.server.requests")`, applied naming conventions will emit the following metrics for different monitoring systems:

- Prometheus: `http_server_requests_seconds`
- Prometheus: `http_server_requests_duration_seconds`
- Atlas: `httpServerRequests`
- Graphite: `http.server.requests`
- InfluxDB: `http_server_requests`
Expand Down Expand Up @@ -571,6 +569,7 @@ public class CustomConfiguration {
if(id.getName().startsWith("myservice")) {
return DistributionStatisticConfig.builder()
.percentiles(0.5, 0.95) // median and 95th percentile, not aggregable
.percentilesHistogram(true) // histogram buckets (e.g. prometheus histogram_quantile)
.build()
.merge(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
</dependency>

</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/micrometer-registry-prometheus/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
</dependency>

</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion extensions/micrometer/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class PrometheusRegistryProcessor {
private static final Logger log = Logger.getLogger(PrometheusRegistryProcessor.class);

static final String REGISTRY_CLASS_NAME = "io.micrometer.prometheusmetrics.PrometheusMeterRegistry";
static final String REGISTRY_CLASS_NAME = "io.micrometer.prometheus.PrometheusMeterRegistry";
static final Class<?> REGISTRY_CLASS = MicrometerRecorder.getClassForName(REGISTRY_CLASS_NAME);

public static class PrometheusEnabled implements BooleanSupplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public void metricsEndpoint() {
.get("/relative/metrics")
.then()
.statusCode(200)
.body(containsString("jvm_total{runtime=\""));
.body(containsString("jvm_info_total{runtime=\""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.quarkus.micrometer.test.Util;
import io.quarkus.test.QuarkusUnitTest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import jakarta.inject.Singleton;

import io.micrometer.core.instrument.Clock;
import io.micrometer.prometheusmetrics.PrometheusConfig;
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry;
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.CollectorRegistry;

@Singleton
public class SecondPrometheusProvider {
@Produces
@Singleton
public PrometheusMeterRegistry registry(PrometheusRegistry collectorRegistry, Clock clock) {
public PrometheusMeterRegistry registry(CollectorRegistry collectorRegistry, Clock clock) {
PrometheusMeterRegistry customRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, collectorRegistry,
clock);
customRegistry.config().commonTags("customKey", "customValue");
Expand Down
8 changes: 1 addition & 7 deletions extensions/micrometer/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<artifactId>micrometer-registry-prometheus-simpleclient</artifactId>
<optional>true</optional>
</dependency>

Expand Down Expand Up @@ -131,12 +131,6 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>nativeimage</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test -->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,13 @@ public void requestReset(HttpRequestMetric requestMetric) {
if (path != null) {
Timer.Sample sample = requestMetric.getSample();

Tags allTags = Tags.of(
VertxMetricsTags.method(requestMetric.request().method()),
HttpCommonTags.uri(path, requestMetric.initialPath, 0, false),
Outcome.CLIENT_ERROR.asTag(),
HttpCommonTags.STATUS_RESET);

allTags = additionalMetrics(requestMetric, null, allTags);

openTelemetryContextUnwrapper.executeInContext(
sample::stop,
requestsTimer.withTags(allTags),
requestsTimer.withTags(Tags.of(
VertxMetricsTags.method(requestMetric.request().method()),
HttpCommonTags.uri(path, requestMetric.initialPath, 0, false),
Outcome.CLIENT_ERROR.asTag(),
HttpCommonTags.STATUS_RESET)),
requestMetric.request().context());
}
requestMetric.requestEnded();
Expand Down Expand Up @@ -218,7 +214,17 @@ public void responseEnd(HttpRequestMetric requestMetric, HttpResponse response,
config.isServerSuppress4xxErrors()),
VertxMetricsTags.outcome(response),
HttpCommonTags.status(response.statusCode()));
allTags = additionalMetrics(requestMetric, response, allTags);
if (!httpServerMetricsTagsContributors.isEmpty()) {
HttpServerMetricsTagsContributor.Context context = new DefaultContext(requestMetric.request(), response);
for (int i = 0; i < httpServerMetricsTagsContributors.size(); i++) {
try {
Tags additionalTags = httpServerMetricsTagsContributors.get(i).contribute(context);
allTags = allTags.and(additionalTags);
} catch (Exception e) {
log.debug("Unable to obtain additional tags", e);
}
}
}

openTelemetryContextUnwrapper.executeInContext(
sample::stop,
Expand All @@ -228,24 +234,6 @@ public void responseEnd(HttpRequestMetric requestMetric, HttpResponse response,
requestMetric.requestEnded();
}

/**
* Make sure same tags are present for the same "http.server.requests" metric because it's defined in 2 places
*/
private Tags additionalMetrics(HttpRequestMetric requestMetric, HttpResponse response, Tags allTags) {
if (!httpServerMetricsTagsContributors.isEmpty()) {
HttpServerMetricsTagsContributor.Context context = new DefaultContext(requestMetric.request(), response);
for (int i = 0; i < httpServerMetricsTagsContributors.size(); i++) {
try {
Tags additionalTags = httpServerMetricsTagsContributors.get(i).contribute(context);
allTags = allTags.and(additionalTags);
} catch (Exception e) {
log.debug("Unable to obtain additional tags", e);
}
}
}
return allTags;
}

/**
* Called when a server web socket connects.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import jakarta.interceptor.Interceptor;

import io.micrometer.core.instrument.Clock;
import io.micrometer.prometheusmetrics.PrometheusConfig;
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry;
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import io.prometheus.metrics.tracer.common.SpanContext;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exemplars.ExemplarSampler;

/**
* This producer is only registered if the {@code quarkus.micrometer.export.prometheus.default-registry} is set to {@code true}.
Expand All @@ -23,8 +23,8 @@ public class PrometheusMeterRegistryProducer {
@Singleton
@Alternative
@Priority(Interceptor.Priority.APPLICATION + 100)
public PrometheusMeterRegistry registry(PrometheusConfig config, PrometheusRegistry collectorRegistry,
Optional<SpanContext> exemplarSampler, Clock clock) {
public PrometheusMeterRegistry registry(PrometheusConfig config, CollectorRegistry collectorRegistry,
Optional<ExemplarSampler> exemplarSampler, Clock clock) {
return new PrometheusMeterRegistry(config, collectorRegistry, clock, exemplarSampler.orElse(null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Singleton;

import io.micrometer.prometheusmetrics.PrometheusConfig;
import io.micrometer.prometheusmetrics.PrometheusDurationNamingConvention;
import io.micrometer.prometheusmetrics.PrometheusNamingConvention;
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusDurationNamingConvention;
import io.micrometer.prometheus.PrometheusNamingConvention;
import io.prometheus.client.CollectorRegistry;
import io.quarkus.arc.DefaultBean;
import io.quarkus.micrometer.runtime.config.runtime.PrometheusRuntimeConfig;

Expand Down Expand Up @@ -39,8 +39,8 @@ public PrometheusDurationNamingConvention durationNamingConvention() {

@Produces
@DefaultBean
public PrometheusRegistry collectorRegistry() {
return new PrometheusRegistry();
public CollectorRegistry collectorRegistry() {
return new CollectorRegistry(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.function.Consumer;

import io.prometheus.client.exporter.common.TextFormat;
import io.quarkus.micrometer.runtime.export.handlers.PrometheusHandler;
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.Handler;
Expand All @@ -11,7 +12,6 @@

@Recorder
public class PrometheusRecorder {

PrometheusHandler handler;

public PrometheusHandler getHandler() {
Expand All @@ -27,7 +27,7 @@ public Consumer<Route> route() {
@Override
public void accept(Route route) {
route.order(1).produces("text/plain");
route.order(2).produces("application/openmetrics-text; version=1.0.0; charset=utf-8");
route.order(2).produces(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import jakarta.enterprise.inject.Produces;

import io.prometheus.metrics.tracer.common.SpanContext;
import io.prometheus.client.exemplars.ExemplarSampler;

public class EmptyExemplarSamplerProvider {

@Produces
public Optional<SpanContext> exemplarSampler() {
public Optional<ExemplarSampler> exemplarSampler() {
return Optional.empty();
}
}
Loading
Loading