The method restricted_registry works by filtering all metrics once at the time of its creation, as one can see from looking at the file registry.py.
If you register a metric after creating the restriction for it, it is not added to the restricted registry - while the docstring could be interpreted as claiming otherwise.
Solution 1: the class could be documented in a way that makes its behaviour explicit;
Solution 2: the class could be expanded to recollect metrics from its parent on every collect() call.
The method
restricted_registryworks by filtering all metrics once at the time of its creation, as one can see from looking at the fileregistry.py.If you register a metric after creating the restriction for it, it is not added to the restricted registry - while the docstring could be interpreted as claiming otherwise.
Solution 1: the class could be documented in a way that makes its behaviour explicit;
Solution 2: the class could be expanded to recollect metrics from its parent on every
collect()call.