restricted_registry() error
See original GitHub issueimport prometheus_client
def queue_current_depth():
ibm_queue_depth_total = prometheus_client.Gauge(
'ibm_queue_depth_total',
'Current queue depth',
['inst']
)
METRICS = ['ibm_queue_depth_total']
REGISTRY = prometheus_client.REGISTRY
# fill the metrics
queues = get_queues()
for queue_name in queues:
current_depth = get_queue_depth(queue_name ) #returns int
ibm_queue_depth_total.labels(inst=queue_name).set(current_depth)
rr = REGISTRY.restricted_registry(METRICS)
File “D:\Projects\uwsgi-flask\ibm_mq_methods\queue_info.py”, line 93, in queue_current_depth rr = REGISTRY.restricted_registry(METRICS) File “D:\Python\lib\site-packages\prometheus_client\registry.py”, line 96, in restricted_registry for metric in collector.collect(): File “D:\Python\lib\site-packages\prometheus_client\metrics.py”, line 68, in collect for suffix, labels, value in self._samples(): File “D:\Python\lib\site-packages\prometheus_client\metrics.py”, line 182, in _multi_samples for suffix, sample_labels, value in metric._samples(): File “D:\Python\lib\site-packages\prometheus_client\metrics.py”, line 175, in _samples return self._child_samples() File “D:\Python\lib\site-packages\prometheus_client\metrics.py”, line 375, in _child_samples return ((‘’, {}, self._value.get()),) AttributeError: ‘tuple’ object has no attribute ‘get’
Hi, guys! I get this error sometimes, honestly, i cant imagine why it’s happen. This script, actually, fill one metric with ~430 labels, and he can work without any kind of error for more then a week. But then, out of a clear sky, an error appears.
In normal conditions, _value object is always MutexValue class object, why it can turn into tuple, or why this tuple may appear?
Thanks for your time and help!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Since i start collect metrics via GaugeMetricFamily and custom registry (see example above) my script runs stable, no errors occure. I think, in that case, i can close the ticket. Brian, I really appreciate your help, thank you so much for what you doing!
Thanks for your suggest, here’s changes:
Hope these changes are similar to what you meant