question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

restricted_registry() error

See original GitHub issue
import 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fetidbellcommented, Jun 18, 2019

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!

0reactions
fetidbellcommented, Jun 11, 2019

Thanks for your suggest, here’s changes:

class QueueInfoCollector(object):
    def __init__(self):
        self.queue_depth_metric = self._add_metric('ibm_queue_depth', 
                'Current queue depth', ['inst'])

    @staticmethod
    def _add_metric(name, documentation, labels):
        g = GaugeMetricFamily(name, documentation, labels=labels)
        return g

    def collect(self):
        return [self.queue_depth_metric]

def queue_current_depth(logger):
    '''Function is check current depth of IBM MQ queues'''
    collector = QueueInfoCollector()
    ibm_queue_depth = collector.queue_depth_metric
    # rest of the code remains the same, except 
    # filling the metrics and getting output
    for queue in response:
        queue_name = queue[pymqi.CMQC.MQCA_Q_NAME].decode('utf-8').strip()
        current_depth = queue[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]
        ibm_queue_depth.add_metric([queue_name], current_depth)
    try:
        output = generate_latest(collector)
    except:
        raise
    return output

Hope these changes are similar to what you meant

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Messages - Registrar's Office | Georgia Tech
Error Description Cont... CLOSED ‑ WAITLIST FULL No regular or waitlist seats available Depa... LEVEL RESTRICTION (Undergrad Students) Depa... OPEN ‑ RESERVED FOR WAIT LIST Seats...
Read more >
You receive an error message when you try to access the ...
Describes how to grant the required permissions to a registry subkey that will allow for remote access to the registry and Event Viewer...
Read more >
10.1. Restricted Registry - Oklahoma.gov
OKDHS staff notifies Restricted Registry staff of receipt of substantiated or confirmed findings when the abuse or neglect occurred to a child ...
Read more >
Registration Errors - Office of the Registrar - UC Merced
Class Restriction. The error is occurring because the course requires a different class standing (Freshman, Sophomore, Junior, Senior, Graduate) than your ...
Read more >
Message 'Requested registry access is not allowed ... - IBM
Message 'Requested registry access is not allowed' when a Controller error occurs for the first time on a restricted client device (for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found