Update MetricsAggregatorService.java (#2272)

This commit is contained in:
Anthony Stirling 2024-11-20 08:20:01 +00:00 committed by GitHub
parent e059caa14e
commit 6c623d8d84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,11 +32,19 @@ public class MetricsAggregatorService {
.counters() .counters()
.forEach( .forEach(
counter -> { counter -> {
String key = String method = counter.getId().getTag("method");
String.format( String uri = counter.getId().getTag("uri");
"http_requests_%s_%s",
counter.getId().getTag("method"), // Skip if either method or uri is null
counter.getId().getTag("uri").replace("/", "_")); if (method == null || uri == null) {
return;
}
String key = String.format(
"http_requests_%s_%s",
method,
uri.replace("/", "_")
);
double currentCount = counter.count(); double currentCount = counter.count();
double lastCount = lastSentMetrics.getOrDefault(key, 0.0); double lastCount = lastSentMetrics.getOrDefault(key, 0.0);