Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove kafka_server_ prefix from Yammer metrics #51

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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