diff options
author | James Socol <me@jamessocol.com> | 2013-03-06 15:12:53 -0500 |
---|---|---|
committer | James Socol <me@jamessocol.com> | 2013-03-06 15:12:53 -0500 |
commit | b479d61e0c4561fe941c9b9b5cef60355ed9e75b (patch) | |
tree | 5ec3cb5f8dac35af0876b19c652efbd60eb38d0f | |
parent | 8351cc7a7d03e9da495165d8c9a40f483e669675 (diff) | |
download | pystatsd-b479d61e0c4561fe941c9b9b5cef60355ed9e75b.tar.gz |
Rewrap docs to 72 chars/line.
[ci skip]
-rw-r--r-- | docs/configure.rst | 45 | ||||
-rw-r--r-- | docs/index.rst | 4 | ||||
-rw-r--r-- | docs/reference.rst | 72 | ||||
-rw-r--r-- | docs/timing.rst | 17 | ||||
-rw-r--r-- | docs/types.rst | 112 |
5 files changed, 128 insertions, 122 deletions
diff --git a/docs/configure.rst b/docs/configure.rst index d42f05e..de95fbe 100644 --- a/docs/configure.rst +++ b/docs/configure.rst @@ -11,16 +11,16 @@ shortcuts available. Runtime ======= -If you are running the statsd_ server locally and on the default port, it's -extremely easy:: +If you are running the statsd_ server locally and on the default port, +it's extremely easy:: from statsd import StatsClient statsd = StatsClient() statsd.incr('foo') -There are three arguments to configure your ``StatsClient`` instance. They, and -their defaults, are:: +There are three arguments to configure your ``StatsClient`` instance. +They, and their defaults, are:: from statsd import StatsClient @@ -28,15 +28,15 @@ their defaults, are:: port=8125, prefix=None) -``host`` is the host running the statsd server. It will support any kind of -name or IP address you might use. +``host`` is the host running the statsd server. It will support any kind +of name or IP address you might use. -``port`` is the statsd server port. The default for both server and client is -``8125``. +``port`` is the statsd server port. The default for both server and +client is ``8125``. -``prefix`` helps distinguish multiple applications or environments using the -same statsd server. It will be prepended to all stats, automatically. For -example:: +``prefix`` helps distinguish multiple applications or environments using +the same statsd server. It will be prepended to all stats, +automatically. For example:: from statsd import StatsClient @@ -46,16 +46,17 @@ example:: foo_stats.incr('baz') bar_stats.incr('baz') -will produce two different stats, ``foo.baz`` and ``bar.baz``. Without the -``prefix`` argument, or with the same ``prefix``, two ``StatsClient`` instances -will update the same stats. +will produce two different stats, ``foo.baz`` and ``bar.baz``. Without +the ``prefix`` argument, or with the same ``prefix``, two +``StatsClient`` instances will update the same stats. In Django ========= -If you are using Statsd in a Django_ application, you can configure a default -``StatsClient`` in the Django settings. All of these settings are optional. +If you are using Statsd in a Django_ application, you can configure a +default ``StatsClient`` in the Django settings. All of these settings +are optional. Here are the settings and their defaults:: @@ -76,9 +77,9 @@ settings can be imported, it won't be available. From the Environment ==================== -Statsd isn't only useful in Django or on the web. A default instance will also -be available if you configure at least two environment variables. These do not -have defaults. +Statsd isn't only useful in Django or on the web. A default instance +will also be available if you configure at least two environment +variables. These do not have defaults. You can set these variables in the environment:: @@ -94,9 +95,9 @@ and then in your Python application, you can simply do:: .. note:: - To make this default instance available, you will need to set at least - ``STATSD_HOST`` and ``STATSD_PORT``, even if using the default values of - ``localhost`` and ``8125``. + To make this default instance available, you will need to set at + least ``STATSD_HOST`` and ``STATSD_PORT``, even if using the default + values of ``localhost`` and ``8125``. .. _statsd: https://github.com/etsy/statsd .. _Django: https://www.djangoproject.com/ diff --git a/docs/index.rst b/docs/index.rst index 57d6d5a..0118c76 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. Python StatsD documentation master file, created by sphinx-quickstart on Mon Apr 9 15:47:23 2012. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. + You can adapt this file completely to your liking, but it should at + least contain the root `toctree` directive. Welcome to Python StatsD's documentation! ========================================= diff --git a/docs/reference.rst b/docs/reference.rst index 2796642..845f239 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -4,14 +4,14 @@ API Reference ============= -The ``StatsClient`` provides accessors for all the types of data the statsd_ -server supports. +The ``StatsClient`` provides accessors for all the types of data the +statsd_ server supports. .. note:: - Each public API method supports a ``rate`` parameter, but statsd doesn't - always use it the same way. See the :ref:`types-chapter` for more - information. + Each public API method supports a ``rate`` parameter, but statsd + doesn't always use it the same way. See the :ref:`types-chapter` for + more information. .. _StatsClient: @@ -23,15 +23,15 @@ server supports. StatsClient(host='localhost', port=8125, prefix=None) -Create a new ``StatsClient`` instance with the appropriate connection and -prefix information. +Create a new ``StatsClient`` instance with the appropriate connection +and prefix information. * ``host``: the hostname or IPv4 address of the statsd_ server. * ``port``: the port of the statsd server. -* ``prefix``: a prefix to distinguish and group stats from an application or - environment. +* ``prefix``: a prefix to distinguish and group stats from an + application or environment. .. _incr: @@ -47,12 +47,12 @@ Increment a :ref:`counter <counter-type>`. * ``stat``: the name of the counter to increment. -* ``count``: the amount to increment by. Typically an integer. May be negative, - but see also :ref:`decr`. +* ``count``: the amount to increment by. Typically an integer. May be + negative, but see also :ref:`decr`. -* ``rate``: a sample rate, a float between 0 and 1. Will only send data this - percentage of the time. The statsd server will take the sample rate into - account for counters. +* ``rate``: a sample rate, a float between 0 and 1. Will only send data + this percentage of the time. The statsd server will take the sample + rate into account for counters. .. _decr: @@ -68,13 +68,13 @@ Decrement a :ref:`counter <counter-type>`. * ``stat``: the name of the counter to decrement. -* ``count``: the amount to decrement by. Typically an integer. May be negative - but that will have the impact of incrementing the counter. See also - :ref:`incr`. +* ``count``: the amount to decrement by. Typically an integer. May be + negative but that will have the impact of incrementing the counter. + See also :ref:`incr`. -* ``rate``: a sample rate, a float between 0 and 1. Will only send data this - percentage of the time. The statsd server will take the sample rate into - account for counters. +* ``rate``: a sample rate, a float between 0 and 1. Will only send data + this percentage of the time. The statsd server will take the sample + rate into account for counters. .. _timing: @@ -90,12 +90,12 @@ Record :ref:`timer <timer-type>` information. * ``stat``: the name of the timer to use. -* ``delta``: the number of milliseconds whatever action took. Should always be - milliseconds. +* ``delta``: the number of milliseconds whatever action took. Should + always be milliseconds. -* ``rate``: a sample rate, a float between 0 and 1. Will only send data this - percentage of the time. The statsd server does *not* take the sample rate - into account for timers. +* ``rate``: a sample rate, a float between 0 and 1. Will only send data + this percentage of the time. The statsd server does *not* take the + sample rate into account for timers. .. _timer: @@ -114,14 +114,14 @@ Record :ref:`timer <timer-type>` information. def foo(): pass -Automatically ecord timing information for a managed block or function call. -See also the :ref:`chapter on timing <timing-chapter>`. +Automatically record timing information for a managed block or function +call. See also the :ref:`chapter on timing <timing-chapter>`. * ``stat``: the name of the timer to use. -* ``rate``: a sample rate, a float between 0 and 1. Will only send data this - percentage of the time. The statsd server does *not* take the sample rate - into account for timers. +* ``rate``: a sample rate, a float between 0 and 1. Will only send data + this percentage of the time. The statsd server does *not* take the + sample rate into account for timers. .. _gauge: @@ -139,15 +139,15 @@ Set a :ref:`gauge <gauge-type>` value. * ``value``: the current value of the gauge. -* ``rate``: a sample rate, a float between 0 and 1. Will only send data this - percentage of the time. The statsd server does *not* take the sample rate - into account for gauges. Use with care. +* ``rate``: a sample rate, a float between 0 and 1. Will only send data + this percentage of the time. The statsd server does *not* take the + sample rate into account for gauges. Use with care. .. note:: - Gauges were added to the statsd server in commit 0ed78be_. If you try to use - this method with an older version of the server, the data will not be - recorded. + Gauges were added to the statsd server in commit 0ed78be_. If you try + to use this method with an older version of the server, the data will + not be recorded. .. _pipeline: diff --git a/docs/timing.rst b/docs/timing.rst index 5dddb71..025647b 100644 --- a/docs/timing.rst +++ b/docs/timing.rst @@ -12,8 +12,8 @@ instrument your code. Calling ``timing`` manually =========================== -The simplest way to use a timer is to record the time yourself and send it -manually, using the :ref:`timing` method:: +The simplest way to use a timer is to record the time yourself and send +it manually, using the :ref:`timing` method:: import time from statsd import StatsClient @@ -31,9 +31,10 @@ manually, using the :ref:`timing` method:: Using a context manager ======================= -Each ``StatsClient`` instance contains a :ref:`timer` attribute that can be -used as a context manager or a decorator. When used as a context manager, it -will automatically report the time taken for the inner block:: +Each ``StatsClient`` instance contains a :ref:`timer` attribute that can +be used as a context manager or a decorator. When used as a context +manager, it will automatically report the time taken for the inner +block:: from statsd import StatsClient @@ -49,9 +50,9 @@ will automatically report the time taken for the inner block:: Using a decorator ================= -The ``timer`` attribute can also be used as a function decorator. Every time -the decorated function is called, the time it took to execute will be sent to -the statsd server. +The ``timer`` attribute can also be used as a function decorator. Every +time the decorated function is called, the time it took to execute will +be sent to the statsd server. :: diff --git a/docs/types.rst b/docs/types.rst index aa7f37e..b6d4daa 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -4,14 +4,14 @@ Data Types ========== -The statsd_ server supports a number of different data types, and performs -different aggregation on each of them. The three main types are *counters*, -*timers*, and *gauges*. +The statsd_ server supports a number of different data types, and +performs different aggregation on each of them. The three main types are +*counters*, *timers*, and *gauges*. The statsd server collects and aggregates in 30 second intervals before -flushing to Graphite_. Graphite usually stores the most recent data in 1-minute -averaged buckets, so when you're looking at a graph, for each stat you are -typically seing the average value over that minute. +flushing to Graphite_. Graphite usually stores the most recent data in +1-minute averaged buckets, so when you're looking at a graph, for each +stat you are typically seing the average value over that minute. .. _counter-type: @@ -19,10 +19,11 @@ typically seing the average value over that minute. Counters ======== -*Counters* are the most basic and default type. They are treated as a count of -a type of event per second, and are, in Graphite_, typically averaged over one -minute. That is, when looking at a graph, you are usually seeing the average -number of events per second during a one-minute period. +*Counters* are the most basic and default type. They are treated as a +count of a type of event per second, and are, in Graphite_, typically +averaged over one minute. That is, when looking at a graph, you are +usually seeing the average number of events per second during a +one-minute period. The statsd server collects counters under the ``stats`` prefix. @@ -35,25 +36,27 @@ Counters are managed with the :ref:`incr` and :ref:`decr` methods of statsd.incr('some.event') -You can increment a counter by more than one by passing a second parameter:: +You can increment a counter by more than one by passing a second +parameter:: statsd.incr('some.other.event', 10) -You can also use the ``rate`` parameter to produce sampled data. The statsd -server will take the sample rate into account, and the ``StatsClient`` will -only send data ``rate`` percent of the time. This can help the statsd server -stay responsive with extremely busy applications. +You can also use the ``rate`` parameter to produce sampled data. The +statsd server will take the sample rate into account, and the +``StatsClient`` will only send data ``rate`` percent of the time. This +can help the statsd server stay responsive with extremely busy +applications. ``rate`` is a float between 0 and 1:: # Increment this counter 10% of the time. statsd.incr('some.third.event', rate=0.1) -Because the statsd server is aware of the sampling, it will still show you the -true average rate per second. +Because the statsd server is aware of the sampling, it will still show +you the true average rate per second. -You can also decrement counters. The ``decr`` method takes the same arguments -as ``incr``:: +You can also decrement counters. The ``decr`` method takes the same +arguments as ``incr``:: statsd.decr('some.other.event') # Decrease the counter by 5, 15% sample. @@ -65,40 +68,40 @@ as ``incr``:: Timers ====== -*Timers* are meant to track how long something took. They are an invaluable -tool for tracking application performance. +*Timers* are meant to track how long something took. They are an +invaluable tool for tracking application performance. -The statsd server collects all timers under the ``stats.timers`` prefix, and -will calculate the lower bound, mean, 90th percentile, upper bound, and count -of each timer for each period (by the time you see it in Graphite, that's -usually per minute). +The statsd server collects all timers under the ``stats.timers`` prefix, +and will calculate the lower bound, mean, 90th percentile, upper bound, +and count of each timer for each period (by the time you see it in +Graphite, that's usually per minute). -* The *lower bound* is the lowest value statsd saw for that stat during that - time period. +* The *lower bound* is the lowest value statsd saw for that stat during + that time period. -* The *mean* is the average of all values statsd saw for that stat during that - time period. +* The *mean* is the average of all values statsd saw for that stat +during that time period. -* The *90th percentile* is a value *x* such that 90% of all the values statsd - saw for that stat during that time period are below *x*, and 10% are above. - This is a great number to try to optimize. +* The *90th percentile* is a value *x* such that 90% of all the values + statsd saw for that stat during that time period are below *x*, and + 10% are above. This is a great number to try to optimize. -* The *upper bound* is the highest value statsd saw for that stat during that - time period. +* The *upper bound* is the highest value statsd saw for that stat during + that time period. -* The *count* is the number of timings statsd saw for that stat during that - time period. It is not averaged. +* The *count* is the number of timings statsd saw for that stat during + that time period. It is not averaged. -The statsd server only operates in millisecond timings. Everything should be -converted to milliseconds. +The statsd server only operates in millisecond timings. Everything +should be converted to milliseconds. -The ``rate`` parameter will sample the data being sent to the statsd server, -but in this case it doesn't make sense for the statsd server to take it into -account (except possibly for the *count* value, but then it would be lying -about how much data it averaged). +The ``rate`` parameter will sample the data being sent to the statsd +server, but in this case it doesn't make sense for the statsd server to +take it into account (except possibly for the *count* value, but then it +would be lying about how much data it averaged). -See the :ref:`timing documentation <timing-chapter>` for more detail on using -timers with Statsd. +See the :ref:`timing documentation <timing-chapter>` for more detail on +using timers with Statsd. .. _gauge-type: @@ -106,20 +109,21 @@ timers with Statsd. Gauges ====== -*Gauges* are a constant data type. They are not subject to averaging, and they -don't change unless you change them. That is, once you set a gauge value, it -will be a flat line on the graph until you change it again. +*Gauges* are a constant data type. They are not subject to averaging, +and they don't change unless you change them. That is, once you set a +gauge value, it will be a flat line on the graph until you change it +again. -Gauges are useful for things that are already averaged, or don't need to reset -periodically. System load, for example, could be graphed with a gauge. You -might use ``incr`` to count the number of logins to a system, but a gauge to -track how many active WebSocket connections you have. +Gauges are useful for things that are already averaged, or don't need to +reset periodically. System load, for example, could be graphed with a +gauge. You might use ``incr`` to count the number of logins to a system, +but a gauge to track how many active WebSocket connections you have. The statsd server collects gauges under the ``stats.gauges`` prefix. -The :ref:`gauge` method also support the ``rate`` parameter to sample data -back to the statsd server, but use it with care, especially with gauges that -may not be updated very often. +The :ref:`gauge` method also support the ``rate`` parameter to sample +data back to the statsd server, but use it with care, especially with +gauges that may not be updated very often. .. _statsd: https://github.com/etsy/statsd |