| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>Statistics and Monitoring - celery.monitoring — Celery v0.3.12 (unstable) documentation</title>    <link rel="stylesheet" href="../static/nature.css" type="text/css" />    <link rel="stylesheet" href="../static/pygments.css" type="text/css" />    <script type="text/javascript">      var DOCUMENTATION_OPTIONS = {        URL_ROOT:    '../',        VERSION:     '0.3.12 (unstable)',        COLLAPSE_MODINDEX: false,        FILE_SUFFIX: '.html',        HAS_SOURCE:  true      };    </script>    <script type="text/javascript" src="../static/jquery.js"></script>    <script type="text/javascript" src="../static/doctools.js"></script>    <link rel="top" title="Celery v0.3.12 (unstable) documentation" href="../index.html" />    <link rel="up" title="Module API Reference" href="index.html" />    <link rel="next" title="Multiprocessing Worker - celery.worker" href="celery.worker.html" />    <link rel="prev" title="Task Discovery - celery.discovery" href="celery.discovery.html" />   </head>  <body>    <div class="related">      <h3>Navigation</h3>      <ul>        <li class="right" style="margin-right: 10px">          <a href="../genindex.html" title="General Index"             accesskey="I">index</a></li>        <li class="right" >          <a href="../modindex.html" title="Global Module Index"             accesskey="M">modules</a> |</li>        <li class="right" >          <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"             accesskey="N">next</a> |</li>        <li class="right" >          <a href="celery.discovery.html" title="Task Discovery - celery.discovery"             accesskey="P">previous</a> |</li>        <li><a href="../index.html">Celery v0.3.12 (unstable) documentation</a> »</li>          <li><a href="index.html" accesskey="U">Module API Reference</a> »</li>       </ul>    </div>      <div class="document">      <div class="documentwrapper">        <div class="bodywrapper">          <div class="body">              <div class="section" id="module-celery.monitoring"><h1>Statistics and Monitoring - celery.monitoring<a class="headerlink" href="#module-celery.monitoring" title="Permalink to this headline">¶</a></h1><p>Publishing Statistics and Monitoring Celery.</p><dl class="class"><dt id="celery.monitoring.Statistics"><em class="property">class </em><tt class="descclassname">celery.monitoring.</tt><tt class="descname">Statistics</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics" title="Permalink to this definition">¶</a></dt><dd><p>Base class for classes publishing celery statistics.</p><dl class="attribute"><dt id="celery.monitoring.Statistics.type"><tt class="descname">type</tt><a class="headerlink" href="#celery.monitoring.Statistics.type" title="Permalink to this definition">¶</a></dt><dd><strong>REQUIRED</strong> The type of statistics this class handles.</dd></dl><p><strong>Required handlers</strong></p><ul class="simple"><li>on_start()</li><li>on_stop()</li></ul><dl class="method"><dt id="celery.monitoring.Statistics.on_start"><tt class="descname">on_start</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.on_start" title="Permalink to this definition">¶</a></dt><dd>What to do when the <a title="celery.monitoring.Statistics.run" class="reference internal" href="#celery.monitoring.Statistics.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> method is called.</dd></dl><dl class="method"><dt id="celery.monitoring.Statistics.on_stop"><tt class="descname">on_stop</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.on_stop" title="Permalink to this definition">¶</a></dt><dd>What to do when the <a title="celery.monitoring.Statistics.stop" class="reference internal" href="#celery.monitoring.Statistics.stop"><tt class="xref docutils literal"><span class="pre">stop()</span></tt></a> method is called.</dd></dl><dl class="method"><dt id="celery.monitoring.Statistics.publish"><tt class="descname">publish</tt><big>(</big><em>**data</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.publish" title="Permalink to this definition">¶</a></dt><dd><p>Publish statistics to be collected later by<a title="celery.monitoring.StatsCollector" class="reference internal" href="#celery.monitoring.StatsCollector"><tt class="xref docutils literal"><span class="pre">StatsCollector</span></tt></a>.</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>data</em> – An arbitrary Python object containing the statisticsto be published.</td></tr></tbody></table></dd></dl><dl class="method"><dt id="celery.monitoring.Statistics.run"><tt class="descname">run</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.run" title="Permalink to this definition">¶</a></dt><dd>Start producing statistics.</dd></dl><dl class="classmethod"><dt id="celery.monitoring.Statistics.start"><em class="property">classmethod </em><tt class="descname">start</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.start" title="Permalink to this definition">¶</a></dt><dd>Convenience method instantiating and running <a title="celery.monitoring.Statistics.run" class="reference internal" href="#celery.monitoring.Statistics.run"><tt class="xref docutils literal"><span class="pre">run()</span></tt></a> inone swoop.</dd></dl><dl class="method"><dt id="celery.monitoring.Statistics.stop"><tt class="descname">stop</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.Statistics.stop" title="Permalink to this definition">¶</a></dt><dd>Stop producing and publish statistics.</dd></dl></dd></dl><dl class="class"><dt id="celery.monitoring.StatsCollector"><em class="property">class </em><tt class="descclassname">celery.monitoring.</tt><tt class="descname">StatsCollector</tt><a class="headerlink" href="#celery.monitoring.StatsCollector" title="Permalink to this definition">¶</a></dt><dd><p>Collect and report Celery statistics.</p><dl class="docutils"><dt><strong>NOTE</strong>: Please run only one collector at any time, or your stats</dt><dd>will be skewed.</dd></dl><dl class="attribute"><dt id="celery.monitoring.StatsCollector.total_tasks_processed"><tt class="descname">total_tasks_processed</tt><a class="headerlink" href="#celery.monitoring.StatsCollector.total_tasks_processed" title="Permalink to this definition">¶</a></dt><dd>The number of tasks executed in total since the first time<a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executed on this class instance.</dd></dl><dl class="attribute"><dt id="celery.monitoring.StatsCollector.total_tasks_processed_by_type"><tt class="descname">total_tasks_processed_by_type</tt><a class="headerlink" href="#celery.monitoring.StatsCollector.total_tasks_processed_by_type" title="Permalink to this definition">¶</a></dt><dd>A dictionary of task names and how many times they have beenexecuted in total since the first time <a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executedon this class instance.</dd></dl><dl class="attribute"><dt id="celery.monitoring.StatsCollector.total_task_time_running"><tt class="descname">total_task_time_running</tt><a class="headerlink" href="#celery.monitoring.StatsCollector.total_task_time_running" title="Permalink to this definition">¶</a></dt><dd>The total time, in seconds, it took to process all the tasks executedsince the first time <a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executed on this classinstance.</dd></dl><dl class="attribute"><dt id="celery.monitoring.StatsCollector.total_task_time_running_by_type"><tt class="descname">total_task_time_running_by_type</tt><a class="headerlink" href="#celery.monitoring.StatsCollector.total_task_time_running_by_type" title="Permalink to this definition">¶</a></dt><dd>A dictionary of task names and their total running time in seconds,counting all the tasks that has been run since the first time<a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executed on this class instance.</dd></dl><dl class="docutils"><dt><strong>NOTE</strong>: You have to run <a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> for these attributes</dt><dd>to be filled.</dd></dl><dl class="method"><dt id="celery.monitoring.StatsCollector.collect"><tt class="descname">collect</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.collect" title="Permalink to this definition">¶</a></dt><dd>Collect any new statistics available since the last time<a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executed.</dd></dl><dl class="method"><dt id="celery.monitoring.StatsCollector.dump_to_cache"><tt class="descname">dump_to_cache</tt><big>(</big><em>cache_key_prefix='celery-statistics'</em><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.dump_to_cache" title="Permalink to this definition">¶</a></dt><dd>Store collected statistics in the cache.</dd></dl><dl class="method"><dt id="celery.monitoring.StatsCollector.report"><tt class="descname">report</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.report" title="Permalink to this definition">¶</a></dt><dd><p>Dump a nice statistics report from the data collected sincethe first time <a title="celery.monitoring.StatsCollector.collect" class="reference internal" href="#celery.monitoring.StatsCollector.collect"><tt class="xref docutils literal"><span class="pre">collect()</span></tt></a> was executed on this instance.</p><p>It outputs the following information:</p><ul><li><dl class="first docutils"><dt>Total processing time by task type and how many times each</dt><dd><p class="first last">task has been excuted.</p></dd></dl></li><li><p class="first">Total task processing time.</p></li><li><p class="first">Total number of tasks executed</p></li></ul></dd></dl><dl class="method"><dt id="celery.monitoring.StatsCollector.task_time_running"><tt class="descname">task_time_running</tt><big>(</big><em>task_id</em>, <em>task_name</em>, <em>args</em>, <em>kwargs</em>, <em>nsecs</em><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.task_time_running" title="Permalink to this definition">¶</a></dt><dd><p>Process statistics regarding how long a task has been running(the :class:TaskTimerStats` class is responsible for sending these).</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"><li><em>task_id</em> – The UUID of the task.</li><li><em>task_name</em> – The name of task.</li><li><em>args</em> – The tasks positional arguments.</li><li><em>kwargs</em> – The tasks keyword arguments.</li><li><em>nsecs</em> – The number of seconds (in <tt class="xref docutils literal"><span class="pre">time.time()</span></tt> format)it took to execute the task.</li></ul></td></tr></tbody></table></dd></dl></dd></dl><dl class="class"><dt id="celery.monitoring.TaskTimerStats"><em class="property">class </em><tt class="descclassname">celery.monitoring.</tt><tt class="descname">TaskTimerStats</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.TaskTimerStats" title="Permalink to this definition">¶</a></dt><dd>Time a running <a title="celery.task.Task" class="reference external" href="celery.task.html#celery.task.Task"><tt class="xref docutils literal"><span class="pre">celery.task.Task</span></tt></a>.</dd></dl><dl class="class"><dt id="celery.monitoring.TimerStats"><em class="property">class </em><tt class="descclassname">celery.monitoring.</tt><tt class="descname">TimerStats</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.TimerStats" title="Permalink to this definition">¶</a></dt><dd><p>A generic timer producing <tt class="docutils literal"><span class="pre">celery</span></tt> statistics.</p><dl class="attribute"><dt id="celery.monitoring.TimerStats.time_start"><tt class="descname">time_start</tt><a class="headerlink" href="#celery.monitoring.TimerStats.time_start" title="Permalink to this definition">¶</a></dt><dd>The time when this class was instantiated (in <tt class="xref docutils literal"><span class="pre">time.time()</span></tt>format.)</dd></dl><dl class="method"><dt id="celery.monitoring.TimerStats.on_finish"><tt class="descname">on_finish</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.monitoring.TimerStats.on_finish" title="Permalink to this definition">¶</a></dt><dd><p>What to do when the timers <tt class="xref docutils literal"><span class="pre">stop()</span></tt> method is called.</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Returns:</th><td class="field-body">the time in seconds it took between calling <tt class="xref docutils literal"><span class="pre">start()</span></tt> onthis class and <tt class="xref docutils literal"><span class="pre">stop()</span></tt>.</td></tr></tbody></table></dd></dl><dl class="method"><dt id="celery.monitoring.TimerStats.on_start"><tt class="descname">on_start</tt><big>(</big><em>task_id</em>, <em>task_name</em>, <em>args</em>, <em>kwargs</em><big>)</big><a class="headerlink" href="#celery.monitoring.TimerStats.on_start" title="Permalink to this definition">¶</a></dt><dd>What to do when the timers <tt class="xref docutils literal"><span class="pre">run()</span></tt> method is called.</dd></dl></dd></dl></div>          </div>        </div>      </div>      <div class="sphinxsidebar">        <div class="sphinxsidebarwrapper">            <h4>Previous topic</h4>            <p class="topless"><a href="celery.discovery.html"                                  title="previous chapter">Task Discovery - celery.discovery</a></p>            <h4>Next topic</h4>            <p class="topless"><a href="celery.worker.html"                                  title="next chapter">Multiprocessing Worker - celery.worker</a></p>            <h3>This Page</h3>            <ul class="this-page-menu">              <li><a href="../sources/reference/celery.monitoring.txt"                     rel="nofollow">Show Source</a></li>            </ul>          <div id="searchbox" style="display: none">            <h3>Quick search</h3>              <form class="search" action="../search.html" method="get">                <input type="text" name="q" size="18" />                <input type="submit" value="Go" />                <input type="hidden" name="check_keywords" value="yes" />                <input type="hidden" name="area" value="default" />              </form>              <p class="searchtip" style="font-size: 90%">              Enter search terms or a module, class or function name.              </p>          </div>          <script type="text/javascript">$('#searchbox').show(0);</script>        </div>      </div>      <div class="clearer"></div>    </div>    <div class="related">      <h3>Navigation</h3>      <ul>        <li class="right" style="margin-right: 10px">          <a href="../genindex.html" title="General Index"             >index</a></li>        <li class="right" >          <a href="../modindex.html" title="Global Module Index"             >modules</a> |</li>        <li class="right" >          <a href="celery.worker.html" title="Multiprocessing Worker - celery.worker"             >next</a> |</li>        <li class="right" >          <a href="celery.discovery.html" title="Task Discovery - celery.discovery"             >previous</a> |</li>        <li><a href="../index.html">Celery v0.3.12 (unstable) documentation</a> »</li>          <li><a href="index.html" >Module API Reference</a> »</li>       </ul>    </div>    <div class="footer">      © Copyright 2009, Ask Solem.      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.    </div>  </body></html>
 |