-
Notifications
You must be signed in to change notification settings - Fork 84
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
Undeterministic order in output #125
Comments
I expect this to be due to the use of Related discussion prometheus/client_golang#483.
While I understand the value of sorted output for the sake of debugging, I am not sure it is worth than the (expected) performance hit. |
That makes sense. My use case here is unit testing where I need to assert on a stable output, so I could even make a potential sorting flag dependent on cfg(test). How about adding optional sorting? |
Have to give this more thought, though not opposed to it. Might as well always do it in debug mode. Again, might be worth exploring replacing the |
The text encoding of metrics is defined by the spec, and the spec doesn't define any sort order, so callers can't assume any sort order. |
I was looking into this for the same reasons as @lstrojny, and found this thread on the https://users.rust-lang.org/t/hashmap-vs-btreemap/13804
It seems like in addition to getting sorting for free, we may be likely to actually see a performance improvement for many cases, as the As @lstrojny notes above, stable output is often very helpful for ensuring deterministic results in unit tests. If the existing hash map behavior needed to be preserved, a similar approach that internally abstracts over the two kinds of maps could offer the benefits of both. The issue linked above prometheus/client_golang#483 also seems to indicate that the Go client also sorts metrics, with the open question there being how to optionally disable sorting for families with an especially large exposition. I'm sympathetic to @08d2's point above, but I see only upside, without any real downside. If we stand to (a) improve performance, (b) improve testing ergonomics, and (c) mirror the behavior of other languages' client libraries by moving to a |
👋 hello! it's been a couple of months so i thought i would follow up on the message above. deterministic output seems like it would be a pleasant improvement, and would likely improve performance. do people have any input on that? |
The output or
encode()
is non-deterministic when creating multiple metrics of the same type.So basically:
This will sometimes return this:
And sometimes this:
I would expect the metrics to be somehow sorted deterministically.
The text was updated successfully, but these errors were encountered: