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

Propose to add GetMetricWithLabelvaluesIfExist fuction to XXXVec struct #1475

Open
ethanvc opened this issue Mar 20, 2024 · 2 comments
Open

Comments

@ethanvc
Copy link

ethanvc commented Mar 20, 2024

Occasionally, developer will set label values that unable to converge, which make lots of metric series. In the worst case, it will oom the target process or consume lots of cpu/memory.

So I want to add a policy to protect my system, the step is:

  1. If the total metric series less then xx count, just do as before(Inc or Add).
  2. If the total metric series above xx count, add an extra check: if the metric already exist, do as before(because just +/-, no extra memory need), otherwise drop the monitor request and report a error monitor event.

To fulfill above protection policy, I need to know if a specified Counter already exist.

So, I hope maybe we can add function like GetMetricWithLabelvaluesIfExist(maybe not this name but have same meaning) to acquire this information: if i get the metric successfully, return the Counter, otherwise return error.

@LandYoungYoung
Copy link

+1

@ArthurSens
Copy link
Member

ArthurSens commented May 13, 2024

The Gatherer interface, implemented by the registry, has the method Gather that returns all metric families that were already collected by the registry.

One could already implement the described behavior by filtering the result by name, but I agree there's a huge inefficiency if you have to loop over all metrics every time you want to do something like that.

I'd agree that extending the Gatherer interface with a method that returns metrics using an array of names as an argument isn't a bad idea. The Registry already has a map of metric descriptor by metric.fqName, so it should be possible?

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

3 participants