Skip to content

Commit

Permalink
Remove kafka_server_ prefix from Yammer metrics (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Mickael Maison <[email protected]>
  • Loading branch information
mimaison authored and scholzj committed Oct 17, 2024
1 parent c5d1077 commit edade01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ public YammerMetricWrapper(String prometheusName, String scope, Metric metric, S
*/
public static String prometheusName(MetricName metricName) {
return PrometheusNaming.prometheusName(
"kafka_server_" +
PrometheusNaming.sanitizeMetricName(
metricName.getGroup() + '_' +
metricName.getType() + '_' +
metricName.getName()).toLowerCase(Locale.ROOT));
PrometheusNaming.sanitizeMetricName(
metricName.getGroup() + '_' +
metricName.getType() + '_' +
metricName.getName()).toLowerCase(Locale.ROOT));
}

static Labels labelsFromScope(String scope, String metricName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void setup() {
@Test
public void testLifeCycle() throws Exception {
YammerPrometheusMetricsReporter reporter = new YammerPrometheusMetricsReporter(registry, collector);
configs.put(PrometheusMetricsReporterConfig.ALLOWLIST_CONFIG, "kafka_server_group_type.*");
configs.put(PrometheusMetricsReporterConfig.ALLOWLIST_CONFIG, "group_type.*");
reporter.init(new VerifiableProperties(configs));

HttpServers.ServerCounter httpServer = null;
Expand All @@ -60,7 +60,7 @@ public void testLifeCycle() throws Exception {
newCounter("group", "type", "name");
metrics = getMetrics(port);
assertEquals(1, metrics.size());
assertEquals("kafka_server_group_type_name_total 0.0", metrics.get(0));
assertEquals("group_type_name_total 0.0", metrics.get(0));

// Removing the metric
removeMetric("group", "type", "name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void testLabelsFromScope() {
@Test
public void testYammerMetricName() {
String metricName = YammerMetricWrapper.prometheusName(new MetricName("Kafka.Server", "Log", "NumLogSegments"));
assertEquals("kafka_server_kafka_server_log_numlogsegments", metricName);
assertEquals("kafka_server_log_numlogsegments", metricName);
}

@Test
Expand Down

0 comments on commit edade01

Please sign in to comment.