celery.monitoring.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Statistics and Monitoring - celery.monitoring &mdash; Celery v0.7.0 (unstable) documentation</title>
  7. <link rel="stylesheet" href="../static/nature.css" type="text/css" />
  8. <link rel="stylesheet" href="../static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../',
  12. VERSION: '0.7.0 (unstable)',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../static/jquery.js"></script>
  19. <script type="text/javascript" src="../static/doctools.js"></script>
  20. <link rel="top" title="Celery v0.7.0 (unstable) documentation" href="../index.html" />
  21. <link rel="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Messaging - celery.messaging" href="celery.messaging.html" />
  23. <link rel="prev" title="Task Discovery - celery.discovery" href="celery.discovery.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="../genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="../modindex.html" title="Global Module Index"
  34. accesskey="M">modules</a> |</li>
  35. <li class="right" >
  36. <a href="celery.messaging.html" title="Messaging - celery.messaging"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.discovery.html" title="Task Discovery - celery.discovery"
  40. accesskey="P">previous</a> |</li>
  41. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  42. <li><a href="index.html" accesskey="U">Module API Reference</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <div class="document">
  46. <div class="documentwrapper">
  47. <div class="bodywrapper">
  48. <div class="body">
  49. <div class="section" id="module-celery.monitoring">
  50. <h1>Statistics and Monitoring - celery.monitoring<a class="headerlink" href="#module-celery.monitoring" title="Permalink to this headline">¶</a></h1>
  51. <p>Publishing Statistics and Monitoring Celery.</p>
  52. <dl class="class">
  53. <dt id="celery.monitoring.Statistics">
  54. <em class="property">
  55. 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>
  56. <dd><p>Base class for classes publishing celery statistics.</p>
  57. <dl class="attribute">
  58. <dt id="celery.monitoring.Statistics.type">
  59. <tt class="descname">type</tt><a class="headerlink" href="#celery.monitoring.Statistics.type" title="Permalink to this definition">¶</a></dt>
  60. <dd><strong>REQUIRED</strong> The type of statistics this class handles.</dd></dl>
  61. <p><strong>Required handlers</strong></p>
  62. <ul class="simple">
  63. <li>on_start()</li>
  64. <li>on_stop()</li>
  65. </ul>
  66. <dl class="method">
  67. <dt id="celery.monitoring.Statistics.on_start">
  68. <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>
  69. <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>
  70. <dl class="method">
  71. <dt id="celery.monitoring.Statistics.on_stop">
  72. <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>
  73. <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>
  74. <dl class="method">
  75. <dt id="celery.monitoring.Statistics.publish">
  76. <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>
  77. <dd><p>Publish statistics to be collected later by
  78. <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>
  79. <table class="docutils field-list" frame="void" rules="none">
  80. <col class="field-name" />
  81. <col class="field-body" />
  82. <tbody valign="top">
  83. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>data</em> &#8211; An arbitrary Python object containing the statistics
  84. to be published.</td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </dd></dl>
  89. <dl class="method">
  90. <dt id="celery.monitoring.Statistics.run">
  91. <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>
  92. <dd>Start producing statistics.</dd></dl>
  93. <dl class="classmethod">
  94. <dt id="celery.monitoring.Statistics.start">
  95. <em class="property">
  96. 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>
  97. <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> in
  98. one swoop.</dd></dl>
  99. <dl class="method">
  100. <dt id="celery.monitoring.Statistics.stop">
  101. <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>
  102. <dd>Stop producing and publish statistics.</dd></dl>
  103. </dd></dl>
  104. <dl class="class">
  105. <dt id="celery.monitoring.StatsCollector">
  106. <em class="property">
  107. 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>
  108. <dd><p>Collect and report Celery statistics.</p>
  109. <dl class="docutils">
  110. <dt><strong>NOTE</strong>: Please run only one collector at any time, or your stats</dt>
  111. <dd>will be skewed.</dd>
  112. </dl>
  113. <dl class="attribute">
  114. <dt id="celery.monitoring.StatsCollector.total_tasks_processed">
  115. <tt class="descname">total_tasks_processed</tt><a class="headerlink" href="#celery.monitoring.StatsCollector.total_tasks_processed" title="Permalink to this definition">¶</a></dt>
  116. <dd>The number of tasks executed in total since the first time
  117. <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>
  118. <dl class="attribute">
  119. <dt id="celery.monitoring.StatsCollector.total_tasks_processed_by_type">
  120. <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>
  121. <dd>A dictionary of task names and how many times they have been
  122. 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
  123. on this class instance.</dd></dl>
  124. <dl class="attribute">
  125. <dt id="celery.monitoring.StatsCollector.total_task_time_running">
  126. <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>
  127. <dd>The total time, in seconds, it took to process all the tasks executed
  128. 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
  129. instance.</dd></dl>
  130. <dl class="attribute">
  131. <dt id="celery.monitoring.StatsCollector.total_task_time_running_by_type">
  132. <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>
  133. <dd>A dictionary of task names and their total running time in seconds,
  134. counting all the tasks that has been run since the first time
  135. <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>
  136. <dl class="docutils">
  137. <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>
  138. <dd>to be filled.</dd>
  139. </dl>
  140. <dl class="method">
  141. <dt id="celery.monitoring.StatsCollector.collect">
  142. <tt class="descname">collect</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.collect" title="Permalink to this definition">¶</a></dt>
  143. <dd>Collect any new statistics available since the last time
  144. <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>
  145. <dl class="method">
  146. <dt id="celery.monitoring.StatsCollector.dump_to_cache">
  147. <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>
  148. <dd>Store collected statistics in the cache.</dd></dl>
  149. <dl class="method">
  150. <dt id="celery.monitoring.StatsCollector.report">
  151. <tt class="descname">report</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.monitoring.StatsCollector.report" title="Permalink to this definition">¶</a></dt>
  152. <dd><p>Dump a nice statistics report from the data collected since
  153. 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 instance.</p>
  154. <p>It outputs the following information:</p>
  155. <ul>
  156. <li><dl class="first docutils">
  157. <dt>Total processing time by task type and how many times each</dt>
  158. <dd><p class="first last">task has been excuted.</p>
  159. </dd>
  160. </dl>
  161. </li>
  162. <li><p class="first">Total task processing time.</p>
  163. </li>
  164. <li><p class="first">Total number of tasks executed</p>
  165. </li>
  166. </ul>
  167. </dd></dl>
  168. <dl class="method">
  169. <dt id="celery.monitoring.StatsCollector.task_time_running">
  170. <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>
  171. <dd><p>Process statistics regarding how long a task has been running
  172. (the :class:TaskTimerStats` class is responsible for sending these).</p>
  173. <table class="docutils field-list" frame="void" rules="none">
  174. <col class="field-name" />
  175. <col class="field-body" />
  176. <tbody valign="top">
  177. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  178. <li><em>task_id</em> &#8211; The UUID of the task.</li>
  179. <li><em>task_name</em> &#8211; The name of task.</li>
  180. <li><em>args</em> &#8211; The tasks positional arguments.</li>
  181. <li><em>kwargs</em> &#8211; The tasks keyword arguments.</li>
  182. <li><em>nsecs</em> &#8211; The number of seconds (in <tt class="xref docutils literal"><span class="pre">time.time()</span></tt> format)
  183. it took to execute the task.</li>
  184. </ul>
  185. </td>
  186. </tr>
  187. </tbody>
  188. </table>
  189. </dd></dl>
  190. </dd></dl>
  191. <dl class="class">
  192. <dt id="celery.monitoring.TaskTimerStats">
  193. <em class="property">
  194. 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>
  195. <dd>Time a running <tt class="xref docutils literal"><span class="pre">celery.task.Task</span></tt>.</dd></dl>
  196. <dl class="class">
  197. <dt id="celery.monitoring.TimerStats">
  198. <em class="property">
  199. 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>
  200. <dd><p>A generic timer producing <tt class="docutils literal"><span class="pre">celery</span></tt> statistics.</p>
  201. <dl class="attribute">
  202. <dt id="celery.monitoring.TimerStats.time_start">
  203. <tt class="descname">time_start</tt><a class="headerlink" href="#celery.monitoring.TimerStats.time_start" title="Permalink to this definition">¶</a></dt>
  204. <dd>The time when this class was instantiated (in <tt class="xref docutils literal"><span class="pre">time.time()</span></tt>
  205. format.)</dd></dl>
  206. <dl class="method">
  207. <dt id="celery.monitoring.TimerStats.on_finish">
  208. <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>
  209. <dd><p>What to do when the timers <tt class="xref docutils literal"><span class="pre">stop()</span></tt> method is called.</p>
  210. <table class="docutils field-list" frame="void" rules="none">
  211. <col class="field-name" />
  212. <col class="field-body" />
  213. <tbody valign="top">
  214. <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> on
  215. this class and <tt class="xref docutils literal"><span class="pre">stop()</span></tt>.</td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </dd></dl>
  220. <dl class="method">
  221. <dt id="celery.monitoring.TimerStats.on_start">
  222. <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>
  223. <dd>What to do when the timers <tt class="xref docutils literal"><span class="pre">run()</span></tt> method is called.</dd></dl>
  224. </dd></dl>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. <div class="sphinxsidebar">
  230. <div class="sphinxsidebarwrapper">
  231. <h4>Previous topic</h4>
  232. <p class="topless"><a href="celery.discovery.html"
  233. title="previous chapter">Task Discovery - celery.discovery</a></p>
  234. <h4>Next topic</h4>
  235. <p class="topless"><a href="celery.messaging.html"
  236. title="next chapter">Messaging - celery.messaging</a></p>
  237. <h3>This Page</h3>
  238. <ul class="this-page-menu">
  239. <li><a href="../sources/reference/celery.monitoring.txt"
  240. rel="nofollow">Show Source</a></li>
  241. </ul>
  242. <div id="searchbox" style="display: none">
  243. <h3>Quick search</h3>
  244. <form class="search" action="../search.html" method="get">
  245. <input type="text" name="q" size="18" />
  246. <input type="submit" value="Go" />
  247. <input type="hidden" name="check_keywords" value="yes" />
  248. <input type="hidden" name="area" value="default" />
  249. </form>
  250. <p class="searchtip" style="font-size: 90%">
  251. Enter search terms or a module, class or function name.
  252. </p>
  253. </div>
  254. <script type="text/javascript">$('#searchbox').show(0);</script>
  255. </div>
  256. </div>
  257. <div class="clearer"></div>
  258. </div>
  259. <div class="related">
  260. <h3>Navigation</h3>
  261. <ul>
  262. <li class="right" style="margin-right: 10px">
  263. <a href="../genindex.html" title="General Index"
  264. >index</a></li>
  265. <li class="right" >
  266. <a href="../modindex.html" title="Global Module Index"
  267. >modules</a> |</li>
  268. <li class="right" >
  269. <a href="celery.messaging.html" title="Messaging - celery.messaging"
  270. >next</a> |</li>
  271. <li class="right" >
  272. <a href="celery.discovery.html" title="Task Discovery - celery.discovery"
  273. >previous</a> |</li>
  274. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  275. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  276. </ul>
  277. </div>
  278. <div class="footer">
  279. &copy; Copyright 2009, Ask Solem.
  280. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  281. </div>
  282. </body>
  283. </html>