Skip to content

Commit

Permalink
Bump prometheus client version from 0.5.0 to 0.15.0 (apache#13785)
Browse files Browse the repository at this point in the history
### Motivation
- prometheus `simpleclient` has broken api, it makes `pulsar-client-origin` can not well used with other libraries
- specify `OpenMetrics`

This PR contains metric name broken changes.

### Modifications
Bump prometheus client version from 0.5.0 to 0.15.0

### changes
- bump the client version
- rename the field prometheus client `UNTYPED` to `UNKNOWN`
- `OpenMetrics`'s counter name needs a `_total` suffix

### metrics name broken changes
- rename `pulsar_expired_token_count` to `pulsar_expired_token_total`
- rename `pulsar_authentication_success_count` to `pulsar_authentication_success_total`
- rename `pulsar_authentication_failures_count` to `pulsar_authentication_failures_total`
- rename `pulsar_sink_sink_exceptions_total_1min` to `pulsar_sink_sink_exceptions_1min_total`
- rename `pulsar_source_received_total_1min` to `pulsar_source_received_1min_total`
- rename `pulsar_source_written_total_1min` to `pulsar_source_written_1min_total`
- rename `pulsar_source_source_total_1min` to `pulsar_source_source_exceptions_1min_total `
- rename `pulsar_source_system_exceptions_total_1min` to `pulsar_source_system_exceptions_1min_total `
- rename `pulsar_function_received_total_1min` to `pulsar_function_received_1min_total `
- rename `pulsar_function_user_exceptions_total_1min` to `pulsar_function_user_exceptions_1min_total`
- rename `pulsar_function_system_exceptions_total_1min` to `pulsar_function_system_exceptions_1min_total`
- rename `pulsar_function_processed_successfully_total_1min` to `pulsar_function_processed_successfully_1min_total`
- rename `pulsar_function_received_total_1min` to `pulsar_function_received_1min_total`
- rename `pulsar_function_user_exceptions_total_1min` to `pulsar_function_user_exceptions_1min_total`
- rename `pulsar_function_system_exceptions_total_1min` to `pulsar_function_system_exceptions_1min_total`
- rename `pulsar_function_processed_successfully_total_1min` to `pulsar_function_processed_successfully_1min_total`
- rename `pulsar_sink_received_total_1min` to `pulsar_sink_received_1min_total`
- rename `pulsar_sink_written_total_1min` to `pulsar_sink_written_1min_total`
- rename `pulsar_sink_sink_exceptions_total_1min` to `pulsar_sink_sink_exceptions_1min_total`
- rename `pulsar_sink_system_exceptions_total_1min` to `pulsar_sink_system_exceptions_1min_total`
- rename `pulsar_sink_received_total_1min` to `pulsar_sink_received_1min_total`
- rename `pulsar_sink_written_total_1min` to `pulsar_sink_written_1min_total`
- rename `pulsar_sink_sink_exceptions_total_1min` to `pulsar_sink_sink_exceptions_1min_total`
- rename `pulsar_sink_system_exceptions_total_1min` to `pulsar_sink_system_exceptions_1min_total`

### Documentation

Check the box below or label this PR directly.

Need to update docs? 

- [x] `doc-required` 
As mentioned above, the metrics name has changed
  • Loading branch information
ZhangJian He authored and gavingaozhangmin committed Jul 14, 2022
1 parent f47bb08 commit 6fddb43
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 94 deletions.
23 changes: 14 additions & 9 deletions distribution/server/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,19 @@ The Apache Software License, Version 2.0
- io.netty-netty-tcnative-boringssl-static-2.0.52.Final-windows-x86_64.jar
- io.netty-netty-tcnative-classes-2.0.52.Final.jar
* Prometheus client
- io.prometheus-simpleclient-0.5.0.jar
- io.prometheus-simpleclient_common-0.5.0.jar
- io.prometheus-simpleclient_hotspot-0.5.0.jar
- io.prometheus-simpleclient_servlet-0.5.0.jar
- io.prometheus-simpleclient_log4j2-0.5.0.jar
- io.prometheus-simpleclient_jetty-0.5.0.jar
- io.prometheus.jmx-collector-0.14.0.jar
- io.prometheus-simpleclient_caffeine-0.5.0.jar
- io.prometheus.jmx-collector-0.16.1.jar
- io.prometheus-simpleclient-0.15.0.jar
- io.prometheus-simpleclient_caffeine-0.15.0.jar
- io.prometheus-simpleclient_common-0.15.0.jar
- io.prometheus-simpleclient_hotspot-0.15.0.jar
- io.prometheus-simpleclient_httpserver-0.15.0.jar
- io.prometheus-simpleclient_jetty-0.15.0.jar
- io.prometheus-simpleclient_log4j2-0.15.0.jar
- io.prometheus-simpleclient_servlet-0.15.0.jar
- io.prometheus-simpleclient_servlet_common-0.15.0.jar
- io.prometheus-simpleclient_tracer_common-0.15.0.jar
- io.prometheus-simpleclient_tracer_otel-0.15.0.jar
- io.prometheus-simpleclient_tracer_otel_agent-0.15.0.jar
* Jakarta Bean Validation API
- jakarta.validation-jakarta.validation-api-2.0.2.jar
- javax.validation-validation-api-1.1.0.Final.jar
Expand Down Expand Up @@ -508,7 +513,7 @@ The Apache Software License, Version 2.0
- io.dropwizard.metrics-metrics-jvm-4.1.12.1.jar
- io.dropwizard.metrics-metrics-jmx-4.1.12.1.jar
* Prometheus
- io.prometheus-simpleclient_httpserver-0.5.0.jar
- io.prometheus-simpleclient_httpserver-0.15.0.jar
* Java JSON WebTokens
- io.jsonwebtoken-jjwt-api-0.11.1.jar
- io.jsonwebtoken-jjwt-impl-0.11.1.jar
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ flexible messaging model and an intuitive client API.</description>
<conscrypt.version>2.5.2</conscrypt.version>
<jersey.version>2.34</jersey.version>
<athenz.version>1.10.50</athenz.version>
<prometheus.version>0.5.0</prometheus.version>
<prometheus.version>0.15.0</prometheus.version>
<vertx.version>3.9.8</vertx.version>
<rocksdb.version>6.29.4.1</rocksdb.version>
<slf4j.version>1.7.32</slf4j.version>
Expand Down Expand Up @@ -179,7 +179,7 @@ flexible messaging model and an intuitive client API.</description>
<hbase.version>2.4.9</hbase.version>
<guava.version>31.0.1-jre</guava.version>
<jcip.version>1.0</jcip.version>
<prometheus-jmx.version>0.14.0</prometheus-jmx.version>
<prometheus-jmx.version>0.16.1</prometheus-jmx.version>
<confluent.version>7.0.1</confluent.version>
<kafka.confluent.schemaregistryclient.version>5.3.0</kafka.confluent.schemaregistryclient.version>
<kafka.confluent.avroserializer.version>5.3.0</kafka.confluent.avroserializer.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AuthenticationProviderToken implements AuthenticationProvider {
static final String TOKEN = "token";

private static final Counter expiredTokenMetrics = Counter.build()
.name("pulsar_expired_token_count")
.name("pulsar_expired_token_total")
.help("Pulsar expired token")
.register();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

public class AuthenticationMetrics {
private static final Counter authSuccessMetrics = Counter.build()
.name("pulsar_authentication_success_count")
.name("pulsar_authentication_success_total")
.help("Pulsar authentication success")
.labelNames("provider_name", "auth_method")
.register();
private static final Counter authFailuresMetrics = Counter.build()
.name("pulsar_authentication_failures_count")
.name("pulsar_authentication_failures_total")
.help("Pulsar authentication failures")
.labelNames("provider_name", "auth_method", "reason")
.register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void generateSystemMetrics(SimpleTextOutputStream stream, String c
Collector.MetricFamilySamples metricFamily = metricFamilySamples.nextElement();

// Write type of metric
stream.write("# TYPE ").write(metricFamily.name).write(' ')
stream.write("# TYPE ").write(metricFamily.name).write(getTypeNameSuffix(metricFamily.type)).write(' ')
.write(getTypeStr(metricFamily.type)).write('\n');

for (int i = 0; i < metricFamily.samples.size(); i++) {
Expand Down Expand Up @@ -88,19 +88,27 @@ public static void generateSystemMetrics(SimpleTextOutputStream stream, String c
}
}

static String getTypeNameSuffix(Collector.Type type) {
if (type.equals(Collector.Type.INFO)) {
return "_info";
}
return "";
}

static String getTypeStr(Collector.Type type) {
switch (type) {
case COUNTER:
return "counter";
case GAUGE:
case INFO:
return "gauge";
case SUMMARY :
case SUMMARY:
return "summary";
case HISTOGRAM:
return "histogram";
case UNTYPED:
case UNKNOWN:
default:
return "untyped";
return "unknown";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,16 @@ public void testDuplicateMetricTypeDefinitions() throws Exception {
if (!typeDefs.containsKey(summaryMetricName)) {
fail("Metric " + metricName + " does not have a corresponding summary type definition");
}
} else if (metricName.endsWith("_created")) {
String summaryMetricName = metricName.substring(0, metricName.indexOf("_created"));
if (!typeDefs.containsKey(summaryMetricName)) {
fail("Metric " + metricName + " does not have a corresponding summary type definition");
}
} else if (metricName.endsWith("_total")) {
String summaryMetricName = metricName.substring(0, metricName.indexOf("_total"));
if (!typeDefs.containsKey(summaryMetricName)) {
fail("Metric " + metricName + " does not have a corresponding counter type definition");
}
} else {
fail("Metric " + metricName + " does not have a type definition");
}
Expand Down Expand Up @@ -1087,7 +1097,7 @@ public String getCommandData() {
PrometheusMetricsGenerator.generate(pulsar, false, false, false, statsOut);
String metricsStr = statsOut.toString();
Multimap<String, Metric> metrics = parseMetrics(metricsStr);
List<Metric> cm = (List<Metric>) metrics.get("pulsar_authentication_success_count");
List<Metric> cm = (List<Metric>) metrics.get("pulsar_authentication_success_total");
boolean haveSucceed = false;
for (Metric metric : cm) {
if (Objects.equals(metric.tags.get("auth_method"), "token")
Expand All @@ -1097,7 +1107,7 @@ public String getCommandData() {
}
Assert.assertTrue(haveSucceed);

cm = (List<Metric>) metrics.get("pulsar_authentication_failures_count");
cm = (List<Metric>) metrics.get("pulsar_authentication_failures_total");

boolean haveFailed = false;
for (Metric metric : cm) {
Expand Down Expand Up @@ -1147,7 +1157,7 @@ public String getCommandData() {
PrometheusMetricsGenerator.generate(pulsar, false, false, false, statsOut);
String metricsStr = statsOut.toString();
Multimap<String, Metric> metrics = parseMetrics(metricsStr);
List<Metric> cm = (List<Metric>) metrics.get("pulsar_expired_token_count");
List<Metric> cm = (List<Metric>) metrics.get("pulsar_expired_token_total");
assertEquals(cm.size(), 1);

provider.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ private void testPulsarSinkLocalRun(String jarFilePathUrl, int parallelism, Stri
assertFalse(metrics.isEmpty());
PulsarFunctionTestUtils.Metric m = metrics.get("pulsar_sink_sink_exceptions_total");
if (m == null) {
m = metrics.get("pulsar_sink_sink_exceptions_total_1min");
m = metrics.get("pulsar_sink_sink_exceptions_1min_total");
}
assertEquals(m.value, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void testPulsarBatchSourceStats(String jarFilePathUrl) throws Exception
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, sourceName));
assertTrue(m.value > 0.0);
m = metrics.get("pulsar_source_received_total_1min");
m = metrics.get("pulsar_source_received_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), sourceName);
Expand All @@ -127,7 +127,7 @@ private void testPulsarBatchSourceStats(String jarFilePathUrl) throws Exception
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, sourceName));
assertTrue(m.value > 0.0);
m = metrics.get("pulsar_source_written_total_1min");
m = metrics.get("pulsar_source_written_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), sourceName);
Expand All @@ -141,7 +141,7 @@ private void testPulsarBatchSourceStats(String jarFilePathUrl) throws Exception
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, sourceName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_source_source_exceptions_total_1min");
m = metrics.get("pulsar_source_source_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), sourceName);
Expand All @@ -155,7 +155,7 @@ private void testPulsarBatchSourceStats(String jarFilePathUrl) throws Exception
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, sourceName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_source_system_exceptions_total_1min");
m = metrics.get("pulsar_source_system_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), sourceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_received_total_1min");
m = metrics.get("pulsar_function_received_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand All @@ -398,7 +398,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_user_exceptions_total_1min");
m = metrics.get("pulsar_function_user_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand Down Expand Up @@ -426,7 +426,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_system_exceptions_total_1min");
m = metrics.get("pulsar_function_system_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand All @@ -447,7 +447,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_processed_successfully_total_1min");
m = metrics.get("pulsar_function_processed_successfully_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand Down Expand Up @@ -544,7 +544,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, (double) totalMsgs);
m = metrics.get("pulsar_function_received_total_1min");
m = metrics.get("pulsar_function_received_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand All @@ -558,7 +558,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_user_exceptions_total_1min");
m = metrics.get("pulsar_function_user_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand Down Expand Up @@ -586,7 +586,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, 0.0);
m = metrics.get("pulsar_function_system_exceptions_total_1min");
m = metrics.get("pulsar_function_system_exceptions_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand All @@ -607,7 +607,7 @@ public void testPulsarFunctionStats() throws Exception {
assertEquals(m.tags.get("namespace"), String.format("%s/%s", tenant, namespacePortion));
assertEquals(m.tags.get("fqfn"), FunctionCommon.getFullyQualifiedName(tenant, namespacePortion, functionName));
assertEquals(m.value, (double) totalMsgs);
m = metrics.get("pulsar_function_processed_successfully_total_1min");
m = metrics.get("pulsar_function_processed_successfully_1min_total");
assertEquals(m.tags.get("cluster"), config.getClusterName());
assertEquals(m.tags.get("instance_id"), "0");
assertEquals(m.tags.get("name"), functionName);
Expand Down
Loading

0 comments on commit 6fddb43

Please sign in to comment.