This is not an issue, just an observation maybe.
Due to the _MetricWrapper, metric classes (Counter, Gauge, Histogram, Summary) are not directly accessible.
Example:
from unittest.mock import Mock
from prometheus_client import Gauge
set_mock = Mock()
Gauge.set = set_mock
g = Gauge('metric', 'Some metric')
g.set(1)
g.set(2)
g.set(3)
g.set(5)
set_mock.assert_called_once()
Output:
AssertionError: Expected 'mock' to have been called once. Called 0 times.
You can circumvent this issue by accessing the __class__ attribute of metric class instance.
Example:
Gauge('foo', 'bar').__class__.set = set_mock
I suggest to make them accessible the same way the functools.update_wrapper does, via __wrapped__ attribute (update_wrapper code) and of course document it.
I'll gladly prepare PR for this!
Thanks for your great work and have a nice day!
This is not an issue, just an observation maybe.
Due to the
_MetricWrapper, metric classes (Counter,Gauge,Histogram,Summary) are not directly accessible.Example:
Output:
You can circumvent this issue by accessing the
__class__attribute of metric class instance.Example:
I suggest to make them accessible the same way the
functools.update_wrapperdoes, via__wrapped__attribute (update_wrapper code) and of course document it.I'll gladly prepare PR for this!
Thanks for your great work and have a nice day!