mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
38 lines
1.3 KiB
ReStructuredText
38 lines
1.3 KiB
ReStructuredText
.. _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
|