Skip to content

Commit

Permalink
Update MetricsAggregatorService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Frooodle authored Nov 20, 2024
1 parent e059caa commit 8378af3
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@ public void aggregateAndSendMetrics() {
.counters()
.forEach(
counter -> {
String key =
String.format(
"http_requests_%s_%s",
counter.getId().getTag("method"),
counter.getId().getTag("uri").replace("/", "_"));
String method = counter.getId().getTag("method");
String uri = counter.getId().getTag("uri");

// Skip if either method or uri is null
if (method == null || uri == null) {
return;
}

String key = String.format(
"http_requests_%s_%s",
method,
uri.replace("/", "_")
);

double currentCount = counter.count();
double lastCount = lastSentMetrics.getOrDefault(key, 0.0);
Expand Down

0 comments on commit 8378af3

Please # to comment.