diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-15 09:10:16 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-15 09:10:21 -0400 |
commit | a1d43c65ccf28597c2fef482dfcd3780fb9b707e (patch) | |
tree | 147a96b51d7930e3e7eeecaf99ba0c97ee761af3 /doc/development | |
parent | 69faac9ae1d4498b4791af40a8e6bb877b82da77 (diff) | |
download | bcfg2-a1d43c65ccf28597c2fef482dfcd3780fb9b707e.tar.gz bcfg2-a1d43c65ccf28597c2fef482dfcd3780fb9b707e.tar.bz2 bcfg2-a1d43c65ccf28597c2fef482dfcd3780fb9b707e.zip |
documented Statistics interface
Diffstat (limited to 'doc/development')
-rw-r--r-- | doc/development/plugins.txt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/development/plugins.txt b/doc/development/plugins.txt index 183126053..a680e7d04 100644 --- a/doc/development/plugins.txt +++ b/doc/development/plugins.txt @@ -156,6 +156,41 @@ For examples, see: :ref:`server-plugins-connectors-puppetenc` plugin is incompatible with aggressive caching. +Tracking Execution Time +----------------------- + +.. versionadded:: 1.3.0 + +Statistics can and should track execution time statistics using +:mod:`Bcfg2.Statistics`. This module tracks execution time for the +server core and for plugins, and exposes that data via ``bcfg2-admin +perf``. This data can be invaluable for locating bottlenecks or other +performance issues. + +The simplest way to track statistics is to use the +:func:`Bcfg2.Server.Plugin.helpers.track_statistics` decorator to +decorate functions that you would like to track execution times for: + +.. code-block:: python + + from Bcfg2.Server.Plugin import track_statistics + + @track_statistics() + def do_something(self, ...): + ... + +This will track the execution time of ``do_something``. + +More granular usage is possible by using :func:`time.time` to manually +determine the execution time of a given event and calling +:func:`Bcfg2.Statistics.Statistics.add_value` with an appropriate +statistic name. + +Bcfg2.Statistics +^^^^^^^^^^^^^^^^ + +.. automodule:: Bcfg2.Statistics + Plugin Helper Classes --------------------- |