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

Replace HashMap with BTreeMap to sort metrics deterministically #128

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lstrojny
Copy link

Addresses #125

Signed-off-by: Lars Strojny <lars@strojny.net>
Signed-off-by: Lars Strojny <lars@strojny.net>
Signed-off-by: Lars Strojny <lars@strojny.net>
Signed-off-by: Lars Strojny <lars@strojny.net>
@08d2
Copy link

08d2 commented Jan 26, 2023

Is sorting metrics in this way guaranteed by the spec?

@lstrojny
Copy link
Author

To my knowledge the spec doesn’t say anything about ordering so an implementation is free to do whatever it chooses to do. The goal here is not to implement any particular ordering but instead implement some deterministic behavior to enable e.g. reliable automated tests.

@08d2
Copy link

08d2 commented Jan 31, 2023

If the spec doesn't define deterministic output, then tests can't rely on any output ordering, right? Tests are written not against implementations but against specifications. However, reliable tests can still be achieved, by sorting the output of metric scrapes within the test, and evaluating against the result of those sorts.

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