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

Rework Desc and ConstMetrics #222

Open
beorn7 opened this issue Aug 16, 2016 · 4 comments
Open

Rework Desc and ConstMetrics #222

beorn7 opened this issue Aug 16, 2016 · 4 comments

Comments

@beorn7
Copy link
Member

beorn7 commented Aug 16, 2016

  • Desc needs to also include bucket layout and type.
  • Desc creation needs to be easier. Consider creating a Desc from an Opts instance, give it a Desc() method. Give Desc a method AddLabelNames.
  • Remove NewInvalidDesc, not needed anywhere (especially with the option of not returning a Desc in Describe at all).
  • ConstMetric creation can then be streamlined: no type parameter needed anymore. Could also take Opts directly but that has a higher performance cost as a Desc has some things precalculated. Needs vetting.
  • There is probably no need for hashing within Desc. It has the risk of hash collisions, and it is not really in the critical path, so it can as well use strings as keys.
@beorn7 beorn7 added the v0.9 label Aug 16, 2016
@beorn7 beorn7 added this to the v0.10 milestone Aug 19, 2016
@beorn7
Copy link
Member Author

beorn7 commented Aug 19, 2016

This should, after all, go into 0.10, as it will break a lot of code.

@beorn7
Copy link
Member Author

beorn7 commented Oct 17, 2016

With the bucket layout in the Desc, validating the bucket layout can be part of validating the Desc, i.e. invalid bucket layouts will show up at registration time. Currently, a panic is triggered during NewHistogram (which is OK) but in a HistogramVec only at the point a new histogram element in the histogram vector is created, i.e. during the WithLabels etc. call. That's sometimes hard to spot, especially if it occurs in the HTTP serving path where panics are recovered by the HTTP library.
@stuartnelson3 FYI

@brian-brazil
Copy link
Contributor

I'd suggest a look at https://github.com/prometheus/client_python#custom-collectors CounterMetricFamily and friends that Python/Java has. It makes the simple cases really easy for custom collectors.

beorn7 pushed a commit that referenced this issue May 10, 2017
- 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
@beorn7
Copy link
Member Author

beorn7 commented May 6, 2019

Note to self to consider #516 to make Desc's useful for generating documentation.

Cori1109 added a commit to Cori1109/client_golang that referenced this issue Jan 9, 2023
- Use local registry to avoid conflicts between tests.
- Expose prometheus/client_golang#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
  prometheus/client_golang#222
@dosubot dosubot bot added the stale label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants