title: Python. prometheus_client ValueError: gauge metric is missing label values
body: <p>I try to use prometheus_client for export RabbitMQ metrics. I have a problem with decorator functions.</p>
  <pre><code>#!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  #from prometheus_client import start_http_server, Summary
  import prometheus_client as prom
  import random
  import time
  
  import pika
  queue_name = [
   &quot;capt&quot;,
   &quot;dev-capt&quot;,
   &quot;myBeautifullTest&quot;
  ]
  
  def get_metric(qname):
    queue_descriptor = channel.queue_declare(qname, durable=True)
    queue_len = queue_descriptor.method.message_count
    return float(queue_len)
  
  
  params = pika.ConnectionParameters(
      host='rabbitmq1.local',
      port=5672,
      credentials=pika.credentials.PlainCredentials('guest11', 'guest22'),
  )
  
  connection = pika.BlockingConnection(parameters=params)
  channel = connection.channel()
  
  i = prom.Info(&quot;RMQPE&quot;, &quot;RabbitMQ Prometheus Exporter&quot;)
  i.info({'version': '0.0.1'})
  
  # Create a metric to track time spent and requests made.
  REQUEST_TIME = prom.Summary('request_processing_seconds', 'Time spent processing request')
  
  # Decorate function with metric.
  @REQUEST_TIME.time()
  def process_request():
      &quot;&quot;&quot;A dummy function that takes some time.&quot;&quot;&quot;
      time.sleep(1)
  
  RABBIT_QUEUE = prom.Gauge('rabbitmq_test_exporter', 'queue_length' , ['queue_name'], multiprocess_mode = 'all')
  for qname in queue_name:
      queue_descriptor = channel.queue_declare(qname, durable=True)
      queue_len = queue_descriptor.method.message_count
      RABBIT_QUEUE.labels(qname).set(queue_len)
  
  @RABBIT_QUEUE.track_inprogress()
  def f():
    pass
  
  with RABBIT_QUEUE.track_inprogress():
    pass
  
  
  
  if __name__ == '__main__':
      # Start up the server to expose the metrics.
      prom.start_http_server(27015)  # Yes, CS port :)
      # Generate some requests.
      while True:
          process_request()
          f()
  </code></pre>
  <p>I have a message:</p>
  <blockquote>
  <p>andrey@xps:~/prj/python3/rmq$ ./prj2.py
  Traceback (most recent call last):
  File &quot;./prj2.py&quot;, line 56, in 
  @RABBIT_QUEUE.track_inprogress()
  File &quot;/usr/local/lib/python3.8/dist-packages/prometheus_client/metrics.py&quot;, line 372, in track_inprogress
  self._raise_if_not_observable()
  File &quot;/usr/local/lib/python3.8/dist-packages/prometheus_client/metrics.py&quot;, line 66, in _raise_if_not_observable
  raise ValueError('%s metric is missing label values' % str(self._type))
  ValueError: gauge metric is missing label values</p>
  </blockquote>
  <p>I need 3 metrics. Maybe more.</p>
  <p>If I remove the decorator, my code is working, but I haven't updated values.</p>
  <p>Please help.</p>
  <p>Thank you.</p>