Skip to content

Commit c4c1c26

Browse files
committed
ZOOKEEPER-4741: Modernize PrometheusMetricsProvider with Jetty and new client
In production environments under heavy load, the existing PrometheusMetricsProvider can introduce high latency. This is largely due to its use of the outdated `io.prometheus.client` (simpleclient 0.x) library and its basic, built-in HTTPServer, which has limitations in server configuration and threading. This commit modernizes the entire component to address these performance and maintainability issues by: 1. **Upgrading to the `io.prometheus.metrics` (client_java 1.x) library.** This aligns the provider with the current standard for Prometheus instrumentation in Java and ensures future compatibility. 2. **Replacing the legacy server and threading model with an embedded Jetty server.** The previous implementation used a custom thread pool for a metrics processing task queue, which is now obsolete in the new client library. This has been replaced with a robust Jetty server, which uses its own configurable thread pool to handle exporter servlet requests directly. This change improves stability and simplifies the threading model, resolving the latency issues under load. These changes make the PrometheusMetricsProvider more stable, performant, maintainable, and easier to configure for production use.
1 parent bec08df commit c4c1c26

File tree

6 files changed

+671
-630
lines changed

6 files changed

+671
-630
lines changed

zookeeper-metrics-providers/zookeeper-prometheus-metrics/pom.xml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>org.apache.zookeeper</groupId>
2525
<artifactId>zookeeper-metrics-providers</artifactId>
26-
<version>3.10.0-SNAPSHOT</version>
26+
<version>3.8.4</version>
2727
</parent>
2828

2929
<artifactId>zookeeper-prometheus-metrics</artifactId>
@@ -32,7 +32,8 @@
3232
<description>ZooKeeper Prometheus.io Metrics Provider implementation</description>
3333

3434
<properties>
35-
<prometheus.version>0.9.0</prometheus.version>
35+
<prometheus.version>1.3.10</prometheus.version>
36+
<jetty.version>9.4.57.v20241219</jetty.version>
3637
</properties>
3738
<dependencies>
3839
<dependency>
@@ -46,28 +47,56 @@
4647
</dependency>
4748
<dependency>
4849
<groupId>io.prometheus</groupId>
49-
<artifactId>simpleclient</artifactId>
50+
<artifactId>prometheus-metrics-core</artifactId>
5051
<version>${prometheus.version}</version>
5152
</dependency>
5253
<dependency>
5354
<groupId>io.prometheus</groupId>
54-
<artifactId>simpleclient_hotspot</artifactId>
55+
<artifactId>prometheus-metrics-instrumentation-jvm</artifactId>
5556
<version>${prometheus.version}</version>
5657
</dependency>
5758
<dependency>
5859
<groupId>io.prometheus</groupId>
59-
<artifactId>simpleclient_servlet</artifactId>
60+
<artifactId>prometheus-metrics-exporter-servlet-javax</artifactId>
6061
<version>${prometheus.version}</version>
6162
</dependency>
6263
<dependency>
63-
<groupId>org.eclipse.jetty</groupId>
64-
<artifactId>jetty-server</artifactId>
65-
<scope>provided</scope>
64+
<groupId>io.prometheus</groupId>
65+
<artifactId>prometheus-metrics-exporter-httpserver</artifactId>
66+
<version>${prometheus.version}</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>io.prometheus</groupId>
70+
<artifactId>prometheus-metrics-exposition-formats</artifactId>
71+
<version>${prometheus.version}</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>io.prometheus</groupId>
75+
<artifactId>prometheus-metrics-config</artifactId>
76+
<version>${prometheus.version}</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.eclipse.jetty</groupId>
80+
<artifactId>jetty-server</artifactId>
81+
<version>${jetty.version}</version>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.eclipse.jetty</groupId>
85+
<artifactId>jetty-servlet</artifactId>
86+
<version>${jetty.version}</version>
87+
</dependency>
88+
<!-- You likely don't need this, but if you do, here's the correct syntax -->
89+
<dependency>
90+
<groupId>org.eclipse.jetty</groupId>
91+
<artifactId>jetty-util</artifactId>
92+
<version>${jetty.version}</version>
93+
<!-- You could add a scope here if needed, e.g., <scope>provided</scope> -->
6694
</dependency>
6795
<dependency>
68-
<groupId>org.eclipse.jetty</groupId>
69-
<artifactId>jetty-servlet</artifactId>
70-
<scope>provided</scope>
96+
<groupId>javax.servlet</groupId>
97+
<artifactId>javax.servlet-api</artifactId>
98+
<version>3.1.0</version>
99+
<scope>provided</scope>
71100
</dependency>
72101
<dependency>
73102
<groupId>org.mockito</groupId>

0 commit comments

Comments
 (0)