mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
cleanup
This commit is contained in:
parent
853744864b
commit
d645159a9f
@ -24,9 +24,6 @@ public class MetricsAggregatorService {
|
|||||||
private final EndpointInspector endpointInspector;
|
private final EndpointInspector endpointInspector;
|
||||||
private final Map<String, Double> lastSentMetrics = new ConcurrentHashMap<>();
|
private final Map<String, Double> lastSentMetrics = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// Flag to decide behavior if no endpoints are discovered
|
|
||||||
private boolean allowAllGetEndpointsIfNoneDiscovered = true;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MetricsAggregatorService(
|
public MetricsAggregatorService(
|
||||||
MeterRegistry meterRegistry,
|
MeterRegistry meterRegistry,
|
||||||
@ -37,17 +34,11 @@ public class MetricsAggregatorService {
|
|||||||
this.endpointInspector = endpointInspector;
|
this.endpointInspector = endpointInspector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(fixedRate = 72000) // Run every 2 hours
|
@Scheduled(fixedRate = 7200000) // Run every 2 hours
|
||||||
public void aggregateAndSendMetrics() {
|
public void aggregateAndSendMetrics() {
|
||||||
Map<String, Object> metrics = new HashMap<>();
|
Map<String, Object> metrics = new HashMap<>();
|
||||||
|
|
||||||
int endpointCount = endpointInspector.getValidGetEndpoints().size();
|
final boolean validateGetEndpoints = endpointInspector.getValidGetEndpoints().size() != 0;
|
||||||
|
|
||||||
boolean validateGetEndpoints = true;
|
|
||||||
if (endpointCount == 0 && allowAllGetEndpointsIfNoneDiscovered) {
|
|
||||||
validateGetEndpoints = false;
|
|
||||||
}
|
|
||||||
final boolean validateGetEndpointsFinal = validateGetEndpoints;
|
|
||||||
Search.in(meterRegistry)
|
Search.in(meterRegistry)
|
||||||
.name("http.requests")
|
.name("http.requests")
|
||||||
.counters()
|
.counters()
|
||||||
@ -81,7 +72,7 @@ public class MetricsAggregatorService {
|
|||||||
}
|
}
|
||||||
// For GET requests, validate if we have a list of valid endpoints
|
// For GET requests, validate if we have a list of valid endpoints
|
||||||
if ("GET".equals(method)
|
if ("GET".equals(method)
|
||||||
&& validateGetEndpointsFinal
|
&& validateGetEndpoints
|
||||||
&& !endpointInspector.isValidGetEndpoint(uri)) {
|
&& !endpointInspector.isValidGetEndpoint(uri)) {
|
||||||
logger.debug("Skipping invalid GET endpoint: {}", uri);
|
logger.debug("Skipping invalid GET endpoint: {}", uri);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user