When initialized without labels, it seems that the resulting metrics objects will lack some instance variables.
Minimal example:
fromprometheus_clientimportGauge, generate_latestcc=Gauge("dummy_count", "POC")
if__name__=='__main__':
cc.set(42)
print(generate_latest().decode()) # OKcc.clear() # raises"""Traceback (most recent call last): File "prom_example.py", line 10, in <module> cc.clear() # raises ^^^^^^^^^^ File …/site-packages/prometheus_client/metrics.py", line 213, in clear with self._lock: ^^^^^^^^^^AttributeError: 'Gauge' object has no attribute '_lock'"""The same code with declared labels will properly clear the metrics data
I came up upon this when adding a new metric and forgetting to add the labels.
(I'm using .clear() to reset the metrics during tests)
When initialized without labels, it seems that the resulting metrics objects will lack some instance variables.
Minimal example:
The same code with declared labels will properly clear the metrics data
I came up upon this when adding a new metric and forgetting to add the labels.
(I'm using
.clear()to reset the metrics during tests)