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
MetricVec constructors do not initialize the underlying prometheus metrics #95115
Comments
/assign @brancz |
@dgrisonnet do you want to give it a try to fix this? |
I can give it a spin but I might need some more insights. For the record, I was able to fix my original problem in metrics-server by forcing the instantiation of the metric by calling the I have two different ideas on how to fix this:
wdyt @brancz? |
/cc @RainbowMango @logicalhan |
The reason why we delay instantiation to the registry is we want to check if the metrics are deprecated or not. I wonder why you need to describe a CounterVec before it is registered? Can you explain more about your cases? |
My use case was in metrics-server's unit tests when we moved from the global registry to the dependency injected ones. To test the metrics, we use the
I solved this by forcing the creation of the metric before calling this function. However, I wonder if this framework's wrapper should be responsible for registering the metric properly.
I wasn't clear enough, but when I mentioned instantiating the underlying collector before registration I was referring to initializing it to a dummy metric. For example, I tried instantiating it to
The goal would be to make the error easier to understand and avoid any segfaults related to the underlying collector not being instantiated. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What happened:
When creating a counter with component-base NewCounterVec and calling metric.Describe(ch), an unexpected segfault occurs.
What you expected to happen:
I was expecting the metric to be describable as when I create it with client_golang NewCounterVec.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
This happens when creating all types of Vec; however, non-Vec metrics such as Counter are not affected by this segfault.
This issue seems to be related to the inner Prometheus metric initialization.
In the NewCounter function, setPrometheusCounter is called. Whereas, in NewCounterVec, the initializeMetric function is not called.
The segfault was left unnoticed because the metric initialization is also done during the metric registration. Thus, to reproduce it we need to call the Describe method before registering the metric.
Environment:
/sig instrumentation
/cc @serathius
The text was updated successfully, but these errors were encountered: