diff --git a/bookkeeper-server/pom.xml b/bookkeeper-server/pom.xml
index 1439466779d..869d54597ad 100644
--- a/bookkeeper-server/pom.xml
+++ b/bookkeeper-server/pom.xml
@@ -102,6 +102,11 @@
circe-checksum
${project.version}
+
+ org.apache.bookkeeper.stats
+ prometheus-metrics-provider
+ ${project.parent.version}
+
commons-cli
commons-cli
@@ -210,12 +215,6 @@
junit-jupiter-api
test
-
- org.apache.bookkeeper.stats
- prometheus-metrics-provider
- ${project.parent.version}
- test
-
org.apache.bookkeeper.stats
otel-metrics-provider
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/MetricsService.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/MetricsService.java
index d3d57f72fa4..35cdb422bf3 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/MetricsService.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/MetricsService.java
@@ -18,6 +18,7 @@
package org.apache.bookkeeper.server.http.service;
+import io.prometheus.client.exporter.common.TextFormat;
import java.io.IOException;
import java.io.StringWriter;
import org.apache.bookkeeper.conf.ServerConfiguration;
@@ -35,8 +36,6 @@
*/
public class MetricsService implements HttpEndpointService {
- public static final String PROMETHEUS_CONTENT_TYPE_004 = "text/plain; version=0.0.4; charset=utf-8";
-
private final ServerConfiguration conf;
private final StatsProvider statsProvider;
@@ -67,7 +66,7 @@ public HttpServiceResponse handle(HttpServiceRequest request) throws Exception {
statsProvider.writeAllMetrics(writer);
writer.flush();
response.setCode(StatusCode.OK);
- response.setContentType(PROMETHEUS_CONTENT_TYPE_004);
+ response.setContentType(TextFormat.CONTENT_TYPE_004);
response.setBody(writer.getBuffer().toString());
} catch (UnsupportedOperationException uoe) {
response.setCode(StatusCode.INTERNAL_ERROR);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/MetricsServiceTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/MetricsServiceTest.java
index c46dfe29976..a8b28cd89ea 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/MetricsServiceTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/MetricsServiceTest.java
@@ -26,6 +26,7 @@
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import io.prometheus.client.exporter.common.TextFormat;
import java.io.IOException;
import java.io.Writer;
import org.apache.bookkeeper.conf.ServerConfiguration;
@@ -89,7 +90,7 @@ public void testWriteMetrics() throws Exception {
HttpServiceResponse response = service.handle(request);
assertEquals(StatusCode.OK.getValue(), response.getStatusCode());
- assertEquals(MetricsService.PROMETHEUS_CONTENT_TYPE_004, response.getContentType());
+ assertEquals(TextFormat.CONTENT_TYPE_004, response.getContentType());
assertEquals(content, response.getBody());
}