From f0b9468ea3314c13621e0553b75e118caf224e9a Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 1 Dec 2014 07:04:10 +0200 Subject: [PATCH] Document statsd_* commands. --- README.rst | 29 -------------------------- docs/source/index.rst | 1 + docs/source/instrumentation.rst | 37 +++++++++++++++++++++++++++++++++ docs/source/settings.rst | 9 ++++++-- gunicorn/config.py | 9 ++++++-- 5 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 docs/source/instrumentation.rst diff --git a/README.rst b/README.rst index a693acac..6bb99beb 100644 --- a/README.rst +++ b/README.rst @@ -45,35 +45,6 @@ Example with test app:: $ gunicorn --workers=2 test:app -Instrumentation ---------------- - -Gunicorn provides an optional instrumentation of the arbiter and -workers using the statsD_ protocol over UDP. Thanks to the -`gunicorn.instrument.statsd` module, Gunicorn becomes a statsD client -The use of UDP cleanly isolates Gunicorn from the receiving end of the statsD -metrics so that instrumentation does not cause Gunicorn to be held up by a slow -statsD consumer. - -To use statsD, just tell gunicorn where the statsD server is: - - $ gunicorn --statsd-host=localhost:8125 ... - -The `Statsd` logger overrides `gunicorn.glogging.Logger` to track -all requests. The following metrics are generated: - - * ``gunicorn.requests``: request rate per second - * ``gunicorn.request.duration``: histogram of request duration (in millisecond) - * ``gunicorn.workers``: number of workers managed by the arbiter (gauge) - * ``gunicorn.log.critical``: rate of critical log messages - * ``gunicorn.log.error``: rate of error log messages - * ``gunicorn.log.warning``: rate of warning log messages - * ``gunicorn.log.exception``: rate of exceptional log messages - -To generate new metrics you can `log.info` with a few additional keywords:: - - log.info("...", extra={"metric": "my.metric", "value": "1.2", "mtype": "gauge"}) - License ------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 180abe0e..30354374 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -40,6 +40,7 @@ Contents run configure settings + instrumentation deploy design signals diff --git a/docs/source/instrumentation.rst b/docs/source/instrumentation.rst new file mode 100644 index 00000000..9da8dd81 --- /dev/null +++ b/docs/source/instrumentation.rst @@ -0,0 +1,37 @@ +.. _instrumentation: + +=============== +Instrumentation +=============== + +.. versionadded:: 19.1 + +Gunicorn provides an optional instrumentation of the arbiter and +workers using the statsD_ protocol over UDP. Thanks to the +``gunicorn.instrument.statsd`` module, Gunicorn becomes a statsD client +The use of UDP cleanly isolates Gunicorn from the receiving end of the statsD +metrics so that instrumentation does not cause Gunicorn to be held up by a slow +statsD consumer. + +To use statsD, just tell gunicorn where the statsD server is: + +.. code-block:: bash + + $ gunicorn --statsd-host=localhost:8125 ... + +The ``Statsd`` logger overrides ``gunicorn.glogging.Logger`` to track +all requests. The following metrics are generated: + +* ``gunicorn.requests``: request rate per second +* ``gunicorn.request.duration``: histogram of request duration (in millisecond) +* ``gunicorn.workers``: number of workers managed by the arbiter (gauge) +* ``gunicorn.log.critical``: rate of critical log messages +* ``gunicorn.log.error``: rate of error log messages +* ``gunicorn.log.warning``: rate of warning log messages +* ``gunicorn.log.exception``: rate of exceptional log messages + +To generate new metrics you can ``log.info`` with a few additional keywords:: + + log.info("...", extra={"metric": "my.metric", "value": "1.2", "mtype": "gauge"}) + +.. _statsD: http://github.com/etsy/statsd diff --git a/docs/source/settings.rst b/docs/source/settings.rst index fbb117ba..3dffa1fe 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -956,7 +956,9 @@ statsd_host * ``--statsd-host STATSD_ADDR`` * ``None`` -host:port of the statsd server to log to +``host:port`` of the statsd server to log to. + +.. versionadded:: 19.1 statsd_prefix ~~~~~~~~~~~~~ @@ -964,5 +966,8 @@ statsd_prefix * ``--statsd-prefix STATSD_PREFIX`` * ```` -Prefix to use when emitting statsd metrics (a trailing . is added, if not provided) +Prefix to use when emitting statsd metrics (a trailing ``.`` is added, +if not provided). + +.. versionadded:: 19.2 diff --git a/gunicorn/config.py b/gunicorn/config.py index 43823198..e39ee451 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -1669,7 +1669,9 @@ class StatsdHost(Setting): default = None validator = validate_hostport desc = """\ - host:port of the statsd server to log to + ``host:port`` of the statsd server to log to. + + .. versionadded:: 19.1 """ class StatsdPrefix(Setting): @@ -1680,5 +1682,8 @@ class StatsdPrefix(Setting): default = "" validator = validate_string desc = """\ - Prefix to use when emitting statsd metrics (a trailing . is added, if not provided) + Prefix to use when emitting statsd metrics (a trailing ``.`` is added, + if not provided). + + .. versionadded:: 19.2 """