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

Initialize counters to zero in debug builds #119

Merged
merged 4 commits into from
Jun 23, 2023
Merged

Initialize counters to zero in debug builds #119

merged 4 commits into from
Jun 23, 2023

Conversation

emschwartz
Copy link
Contributor

@emschwartz emschwartz commented Jun 22, 2023

This uses the linkme::distributed_slice macro to collect all of the function details into a slice at compile/link time. Then, when the prometheus_exporter::init function is called, all of the function counters are set to zero.

If we had a general autometrics initialization function (#117), we might want to move the counter initialization into there.

Alternatively, if we wanted to ensure that this is run without having an explicit initialization function, I think we could use ctor to initialize the counters.

Resolves #70

@emschwartz emschwartz enabled auto-merge (squash) June 23, 2023 13:14
@emschwartz emschwartz merged commit dd902ac into main Jun 23, 2023
1 check passed
@emschwartz emschwartz deleted the zero-counters branch June 23, 2023 13:16
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.

Initialize all metrics to zero
2 participants