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

Label order in textformat #249

Open
kwiesmueller opened this issue Jul 20, 2022 · 1 comment
Open

Label order in textformat #249

kwiesmueller opened this issue Jul 20, 2022 · 1 comment

Comments

@kwiesmueller
Copy link

One thing I'm missing from the textformat is, that the order of label keys is expected to remain consistent in a single scrape of a histogram bucket

So, good:

# TYPE foo histogram
foo_bucket{a=x,b=x,le="0.0"} 0
foo_bucket{a=x,b=x,le="0.1"} 8
foo_bucket{a=x,b=x,le="+Inf"} 17

And bad:

# TYPE foo histogram
foo_bucket{a=x,b=x,le="0.0"} 0
foo_bucket{b=x,a=x,le="0.1"} 8 # here a and b are switched
foo_bucket{a=x,b=x,le="+Inf"} 17

This guarantee could help parsers be more efficient as they can compare labels using simple string comparing vs. decoding the labels into maps first and then comparing those.

@brian-brazil
Copy link
Contributor

The 2nd example is sufficient in my experience (though weird), the more important thing is that it's consistent from scrape to scrape which is encouraged by the spec but not required so that you can cache the labels and do a hash lookup across scrapes.

Making it consistent from scrape to scrape is also likely going to make it consistent within a scape, as the easiest way is some form of sorting. So I don't think this requires any changes in the spec, as it'll already largely ensure this.

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

No branches or pull requests

2 participants