SkeLLLa / fastify-metrics

Prometheus metrics exporter for Fastify
https://savelife.in.ua/en/donate-en/
MIT License
96 stars 33 forks source link

fix: only start timers if they are enabled via configuration option #97

Closed Neriuzz closed 9 months ago

Neriuzz commented 9 months ago

Hey again,

My last PR seems like it might have a nasty memory leak, as the summary and histogram timers would get started on every request even if they have been disabled via the configuration option.

This PR fixes that issue by only initialising the timers if the relevant histogram/summary collection has been enabled.

codecov[bot] commented 9 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c0cb240) 99.39% compared to head (0057ce7) 98.82%. Report is 1 commits behind head on master.

Files Patch % Lines
src/fastify-metrics.ts 88.23% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #97 +/- ## ========================================== - Coverage 99.39% 98.82% -0.58% ========================================== Files 2 2 Lines 165 170 +5 Branches 64 70 +6 ========================================== + Hits 164 168 +4 Misses 1 1 - Partials 0 1 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 9 months ago

:tada: This PR is included in version 10.4.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: