rkosegi / netflow-collector

Simple Netflow V5 exporter for prometheus
Apache License 2.0
9 stars 3 forks source link

fix: occasional 500 error when being scraped for metrics #81

Closed aeijdenberg closed 2 months ago

aeijdenberg commented 2 months ago

We are seeing errors on the /metrics end-point suggesting that the same metric is attempted to being exported more than once during the same collect.

I suspect this is because the ttlcache.Range() function doesn't grab a mutex for the entire loop, and that the cleanup or other modication is causing the same values to be emitted more than once during the same iteration.

This change gets a copy of the map then iterates over that, and hopefully stops that error condition from manifesting itself.

(We'll keep an eye on for a while to see if this re-occurs, but wanted to open the PR early in case the previous change is breaking anyone else)

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud