Skip to content

Commit

Permalink
Revert "fix: use existing prometheus content type constant"
Browse files Browse the repository at this point in the history
This reverts commit c265c49.
  • Loading branch information
tomjo committed Mar 5, 2024
1 parent 1602409 commit 9d8b7eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions bookkeeper-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
<artifactId>circe-checksum</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper.stats</groupId>
<artifactId>prometheus-metrics-provider</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down Expand Up @@ -215,6 +210,12 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper.stats</groupId>
<artifactId>prometheus-metrics-provider</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper.stats</groupId>
<artifactId>otel-metrics-provider</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

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;
Expand All @@ -36,6 +35,8 @@
*/
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;

Expand Down Expand Up @@ -66,7 +67,7 @@ public HttpServiceResponse handle(HttpServiceRequest request) throws Exception {
statsProvider.writeAllMetrics(writer);
writer.flush();
response.setCode(StatusCode.OK);
response.setContentType(TextFormat.CONTENT_TYPE_004);
response.setContentType(PROMETHEUS_CONTENT_TYPE_004);
response.setBody(writer.getBuffer().toString());
} catch (UnsupportedOperationException uoe) {
response.setCode(StatusCode.INTERNAL_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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;
Expand Down Expand Up @@ -90,7 +89,7 @@ public void testWriteMetrics() throws Exception {
HttpServiceResponse response = service.handle(request);

assertEquals(StatusCode.OK.getValue(), response.getStatusCode());
assertEquals(TextFormat.CONTENT_TYPE_004, response.getContentType());
assertEquals(MetricsService.PROMETHEUS_CONTENT_TYPE_004, response.getContentType());
assertEquals(content, response.getBody());
}

Expand Down

0 comments on commit 9d8b7eb

Please sign in to comment.