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

Metric for label set has incorrect name exposed in multiprocess mode #1035

Open
jarni-ua opened this issue May 23, 2024 · 0 comments
Open

Metric for label set has incorrect name exposed in multiprocess mode #1035

jarni-ua opened this issue May 23, 2024 · 0 comments
Labels

Comments

@jarni-ua
Copy link

jarni-ua commented May 23, 2024

The following piece of code from the metrics.py

        with self._lock:
            if labelvalues not in self._metrics:
                self._metrics[labelvalues] = self.__class__(
                    self._name,
                    documentation=self._documentation,
                    labelnames=self._labelnames,
                    unit=self._unit,
                    _labelvalues=labelvalues,
                    **self._kwargs
                )

passes the self._name as name parameter in the ctor. The problem is that at this point self._name is actually a full name created by _build_full_name(), for example mynamespace_mysubsystem_mymetric_myunit. Unfortunately, this name undergoes a second round of full name construction. In case of default ctor, where namespace, subsystem and unit all have str = '' default value, this is not a big deal. But if a library user has custom ctor with non-empty default values it causes a pretty weird name to be produced:

mydefaultnamespace_mydefaultsubsystem_mynamespace_mysubsystem_mymetric_myunit_mydefaultunit

Now, in non-multiprocess mode this is not a problem as collector takes the metric name from the parent metric and simply append the child metric labels and values. But multiprocess collector takes what is present in the process files, and those have child metric names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants