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

Expensive metric validation in debug mode #52

Open
3 tasks
mxinden opened this issue Mar 11, 2022 · 9 comments
Open
3 tasks

Expensive metric validation in debug mode #52

mxinden opened this issue Mar 11, 2022 · 9 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mxinden
Copy link
Member

mxinden commented Mar 11, 2022

When run in debug mode, I think it is worth exploring running different validations on the registered metrics.

Examples:

I think a goal worth striving for is keeping the dependency tree small for the sake of compile times.

@AbhijithGanesh
Copy link

AbhijithGanesh commented Aug 8, 2022

Heyy Max, I would like to work on this!

@mxinden
Copy link
Member Author

mxinden commented Aug 10, 2022

Great. Let me know in case you need any help @AbhijithGanesh.

@AbhijithGanesh
Copy link

AbhijithGanesh commented Aug 10, 2022

Definitely @mxinden

@AbhijithGanesh
Copy link

Can you explain about the expensive part of validating ? Does this mean this is taking more time/process ?

@mxinden
Copy link
Member Author

mxinden commented Aug 13, 2022

Yes, correct, expensive in terms of hardware resources.

@AbhijithGanesh
Copy link

so here, I am trying to ensure the Registry::register doesn't allow duplication and optimize this for testing situations

@chylex
Copy link

chylex commented Dec 15, 2022

I ran into an issue with a Family<String, Counter>. I thought this was valid since I only wanted one label, and that if this was not valid then the library would reject it at compile time or at least runtime, but encode ran without error and output something that was not valid openmetrics-text format:

# HELP apache_requests Number of received requests.
# TYPE apache_requests counter
apache_requests_total{first} 1
# EOF

This caused Prometheus to fail scraping with expected equal, got "BCLOSE". It would be nice if either the Family type definition, or at least the encode function could check that the labels are in a valid format.

@mxinden
Copy link
Member Author

mxinden commented Dec 19, 2022

@chylex thanks for reporting here.

In general, yes I am in favor of checking proper formatting of labels in debug mode.

In your particular case, I am guessing that you provided an enum with Encode derived to the Family, correct? This is now impossible at compile time with #105. See latest alpha release. Would appreciate you testing this out.

@chylex
Copy link

chylex commented Dec 19, 2022

@chylex thanks for reporting here.

In general, yes I am in favor of checking proper formatting of labels in debug mode.

In your particular case, I am guessing that you provided an enum with Encode derived to the Family, correct? This is now impossible at compile time with #105. See latest alpha release. Would appreciate you testing this out.

I provided what I considered to be the value of my label. I was missing the name of the label because I didn't learn how labels work properly, and thought that since I only had one "label", I should just pass its value.

The library didn't complain that Family<String, Counter> was a Family type that could never produce a valid encoding, and it proceeded to generate the invalid encoding which caused an error during scraping.

Once I found the issue, I corrected the Family type for my single-label metric to Family<(&'static str, String), Counter>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants