Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config setting if the collector registry should be wiped #26

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

ekateiva
Copy link
Contributor

@ekateiva ekateiva commented Jan 3, 2024

TL;DR;

We can't wipe metrics on each metrics render, if we want to use Counter metric.

Why this change?

I am working to introduce Counter metric type. This metrics works a bit different than Gauge. Counter could be set somewhere in the code and executed multiple times during the period between data sync to Prometheus. Of course, for this we need to use different Storage (not InMemory). But this is a different topic, and right now it can be overwritten in the container. In the future maybe this package could also have a storage setting.
And Counter value always goes up, so we don't need to wipe the storage on each request. Also, I don't see a reason, why we should wipe it for InMemory storage as well, as the Gauge exporters right now works in the same request cycle.

Some packages already have such a setting and is off by default:

Others don't have such setting, but don't wipe as well:

Looking forward to hear your opinion on that. Otherwise, we need to override the RenderAction just to remove $this->registry->wipeStorage(); line. So maybe it's better to have in the package under the setting.

The previous test case was not very realistic, as it would be two different request cycles, so it is better to test those cases separetly.
@freekmurze freekmurze merged commit f8d2c63 into spatie:main Jan 3, 2024
5 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants