Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: Unrecognized option 'task-runtime-metric-buckets' when accessing 'events' key in shelve db file #1328

Open
krishnakumar18 opened this issue Sep 27, 2023 · 1 comment
Labels

Comments

@krishnakumar18
Copy link

krishnakumar18 commented Sep 27, 2023

I'm running the flower app with persistent and db options to save the task statues to the file flower.db. When i try to open this shelve file and print the keys present in it, i only get one key events. When i try to access the value of db[events], i get the following error in Prometheus client, AttributeError: Unrecognized option 'task-runtime-metric-buckets'

How i start the flower app :-
celery -A project --broker=broker_url flower --port=5555 --persistent=True --db=flower_db.db

The code i used to read from the shelve file :-

import shelve
with shelve.open("flower_db.db", 'r') as db:
    keys = db.keys()
    # the for loop below prints `events`
    for key in keys:
        print(key)
    # this print statement errors out
    print(db['events'])

This is the full trace of the error :-

File ~/opt/anaconda3/lib/python3.10/site-packages/flower/events.py:72, in EventsState.__init__(self, *args, **kwargs)
     70 super(EventsState, self).__init__(*args, **kwargs)
     71 self.counter = collections.defaultdict(Counter)
---> 72 self.metrics = get_prometheus_metrics()

File ~/opt/anaconda3/lib/python3.10/site-packages/flower/events.py:31, in get_prometheus_metrics()
     29 global prometheus_metrics
     30 if prometheus_metrics is None:
---> 31     prometheus_metrics = PrometheusMetrics()
     33 return prometheus_metrics

File ~/opt/anaconda3/lib/python3.10/site-packages/flower/events.py:46, in PrometheusMetrics.__init__(self)
     39 self.events = PrometheusCounter('flower_events_total', "Number of events", ['worker', 'type', 'task'])
     42 self.runtime = Histogram(
     43     'flower_task_runtime_seconds',
     44     "Task runtime",
     45     ['worker', 'task'],
---> 46     buckets=options.task_runtime_metric_buckets
     47 )
     48 self.prefetch_time = Gauge(
     49     'flower_task_prefetch_time_seconds',
     50     "The time the task spent waiting at the celery worker to be executed.",
     51     ['worker', 'task']
     52 )
     53 self.number_of_prefetched_tasks = Gauge(
     54     'flower_worker_prefetched_tasks',
     55     'Number of tasks of given type prefetched at a worker',
     56     ['worker', 'task']
     57 )

File ~/opt/anaconda3/lib/python3.10/site-packages/tornado/options.py:158, in OptionParser.__getattr__(self, name)
    156 if isinstance(self._options.get(name), _Option):
    157     return self._options[name].value()
--> 158 raise AttributeError("Unrecognized option %r" % name)

AttributeError: Unrecognized option 'task-runtime-metric-buckets'

To Reproduce
Steps to reproduce the behavior:

  1. Run flower app with persistent and db settings
  2. Read the shelve file specified in db settings in python
  3. Print the value of the key events

Expected behavior
db[events] should print the list of events that flower collected

System information

flower   -> flower:1.2.0 tornado:6.3.3 humanize:4.8.0
software -> celery:5.3.1 (emerald-rush) kombu:5.3.1 py:3.10.13
            billiard:4.1.0 py-amqp:5.1.1
platform -> system:Darwin arch:64bit
            kernel version:21.5.0 imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:amqp results:disabled

deprecated_settings: None
@krishnakumar18
Copy link
Author

This could be related to this issue :- #1134
Tagging the relevant folks :- @mher @Tomasz-Kluczkowski. Please take a look at this issue.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant