Statistics and Monitoring - celery.monitoring
Publishing Statistics and Monitoring Celery.
- 
class celery.monitoring.Statistics(**kwargs)
 
Base class for classes publishing celery statistics.
- 
type
 
- REQUIRED The type of statistics this class handles.
 
Required handlers
- 
on_start(*args, **kwargs)
 
- What to do when the run() method is called.
 
- 
on_stop(*args, **kwargs)
 
- What to do when the stop() method is called.
 
- 
publish(**data)
 
Publish statistics to be collected later by
StatsCollector.
| Parameter: | data – An arbitrary Python object containing the statistics
to be published. | 
- 
run(*args, **kwargs)
 
- Start producing statistics.
 
- 
classmethod start(*args, **kwargs)
 
- Convenience method instantiating and running run() in
one swoop.
 
- 
stop(*args, **kwargs)
 
- Stop producing and publish statistics.
 
- 
class celery.monitoring.StatsCollector
 
Collect and report Celery statistics.
- NOTE: Please run only one collector at any time, or your stats
 
- will be skewed.
 
- 
total_tasks_processed
 
- The number of tasks executed in total since the first time
collect() was executed on this class instance.
 
- 
total_tasks_processed_by_type
 
- A dictionary of task names and how many times they have been
executed in total since the first time collect() was executed
on this class instance.
 
- 
total_task_time_running
 
- The total time, in seconds, it took to process all the tasks executed
since the first time collect() was executed on this class
instance.
 
- 
total_task_time_running_by_type
 
- A dictionary of task names and their total running time in seconds,
counting all the tasks that has been run since the first time
collect() was executed on this class instance.
 
- NOTE: You have to run collect() for these attributes
 
- to be filled.
 
- 
collect()
 
- Collect any new statistics available since the last time
collect() was executed.
 
- 
dump_to_cache(cache_key_prefix='celery-statistics')
 
- Store collected statistics in the cache.
 
- 
report()
 
Dump a nice statistics report from the data collected since
the first time collect() was executed on this instance.
It outputs the following information:
- 
task_time_running(task_id, task_name, args, kwargs, nsecs)
 
Process statistics regarding how long a task has been running
(the :class:TaskTimerStats` class is responsible for sending these).
| Parameters: | 
- task_id – The UUID of the task.
 
- task_name – The name of task.
 
- args – The tasks positional arguments.
 
- kwargs – The tasks keyword arguments.
 
- nsecs – The number of seconds (in time.time() format)
it took to execute the task.
 
 
 | 
- 
class celery.monitoring.TaskTimerStats(**kwargs)
 
- Time a running celery.task.Task.
 
- 
class celery.monitoring.TimerStats(**kwargs)
 
A generic timer producing celery statistics.
- 
time_start
 
- The time when this class was instantiated (in time.time()
format.)
 
- 
on_finish()
 
What to do when the timers stop() method is called.
| Returns: | the time in seconds it took between calling start() on
this class and stop(). | 
- 
on_start(task_id, task_name, args, kwargs)
 
- What to do when the timers run() method is called.