From 6c623d8d84e5774d4c64f9aea95ff3962ea11038 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:20:01 +0000 Subject: [PATCH] Update MetricsAggregatorService.java (#2272) --- .../SPDF/service/MetricsAggregatorService.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/service/MetricsAggregatorService.java b/src/main/java/stirling/software/SPDF/service/MetricsAggregatorService.java index eb3a83b0..8a650299 100644 --- a/src/main/java/stirling/software/SPDF/service/MetricsAggregatorService.java +++ b/src/main/java/stirling/software/SPDF/service/MetricsAggregatorService.java @@ -32,11 +32,19 @@ public class MetricsAggregatorService { .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);