Skip to content

Improve promhttp middleware #302

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

Merged
merged 2 commits into from
May 11, 2017
Merged

Improve promhttp middleware #302

merged 2 commits into from
May 11, 2017

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented May 10, 2017

See commit descriptions.

Fixes #299 .

@stuartnelson3

beorn7 added 2 commits May 10, 2017 19:49
- Use local registry to avoid conflicts between tests.
- Expose #299 by
  using ConstLabels in a test.
- Improve example: Buckets and help string must be consistent, even
  if the former is not enforced as of now, but see
  #222
Copy link
Contributor

@stuartnelson3 stuartnelson3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's working, but if you have the time to explain why the value == magicString when name is code or metric, that would be much appreciated :)

@beorn7
Copy link
Member Author

beorn7 commented May 11, 2017

As it says: It's magic! Nothing to explain, it just works.

In fact, it's quite easy to explain: The problem was that we want to allow arbitrary const labels but we couldn't recognize them in the metric protobuf. All labels look the same there. So what I'm doing here is to set the label value of the one or two normal labels (which must be code or method) to the magic string, i.e. a string that will never occur otherwise. Then, all the labels with the magic string as a label are guaranteed to not be const labels. From there on, we can do the check as normal.

@beorn7 beorn7 merged commit 42552c1 into master May 11, 2017
@beorn7 beorn7 deleted the beorn7/http branch May 11, 2017 14:12
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