Name | python-statsd JSON |
Version |
2.1.0
JSON |
| download |
home_page | https://github.com/WoLpH/python-statsd |
Summary | statsd is a client for Etsy's node-js statsd server. A proxy for the Graphite stats collection and graphing server. |
upload_time | 2017-09-05 02:02:33 |
maintainer | |
docs_url | https://pythonhosted.org/python-statsd/ |
author | Rick van Hattem |
requires_python | |
license | BSD |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
|
coveralls test coverage |
|
Introduction
============
.. image:: https://travis-ci.org/WoLpH/python-statsd.svg?branch=master
:alt: Test Status
:target: https://travis-ci.org/WoLpH/python-statsd
.. image:: https://coveralls.io/repos/WoLpH/python-statsd/badge.svg?branch=master
:alt: Coverage Status
:target: https://coveralls.io/r/WoLpH/python-statsd?branch=master
`statsd` is a client for Etsy's statsd server, a front end/proxy for the
Graphite stats collection and graphing server.
Links
-----
- The source: https://github.com/WoLpH/python-statsd
- Project page: https://pypi.python.org/pypi/python-statsd
- Reporting bugs: https://github.com/WoLpH/python-statsd/issues
- Documentation: http://python-statsd.readthedocs.io/en/latest/
- My blog: http://w.wol.ph/
- Statsd: https://github.com/etsy/statsd
- Graphite: http://graphite.wikidot.com
Install
-------
To install simply execute `python setup.py install`.
If you want to run the tests first, run `python setup.py nosetests`
Usage
-----
To get started real quick, just try something like this:
Basic Usage
~~~~~~~~~~~
Timers
^^^^^^
>>> import statsd
>>>
>>> timer = statsd.Timer('MyApplication')
>>>
>>> timer.start()
>>> # do something here
>>> timer.stop('SomeTimer')
Counters
^^^^^^^^
>>> import statsd
>>>
>>> counter = statsd.Counter('MyApplication')
>>> # do something here
>>> counter += 1
Gauge
^^^^^
>>> import statsd
>>>
>>> gauge = statsd.Gauge('MyApplication')
>>> # do something here
>>> gauge.send('SomeName', value)
Raw
^^^
Raw strings should be e.g. pre-summarized data or other data that will
get passed directly to carbon. This can be used as a time and
bandwidth-saving mechanism sending a lot of samples could use a lot of
bandwidth (more b/w is used in udp headers than data for a gauge, for
instance).
>>> import statsd
>>>
>>> raw = statsd.Raw('MyApplication', connection)
>>> # do something here
>>> raw.send('SomeName', value, timestamp)
The raw type wants to have a timestamp in seconds since the epoch (the
standard unix timestamp, e.g. the output of "date +%s"), but if you leave it out or
provide None it will provide the current time as part of the message
Average
^^^^^^^
>>> import statsd
>>>
>>> average = statsd.Average('MyApplication', connection)
>>> # do something here
>>> average.send('SomeName', 'somekey:%d'.format(value))
Connection settings
^^^^^^^^^^^^^^^^^^^
If you need some settings other than the defaults for your ``Connection``,
you can use ``Connection.set_defaults()``.
>>> import statsd
>>> statsd.Connection.set_defaults(host='localhost', port=8125, sample_rate=1, disabled=False)
Every interaction with statsd after these are set will use whatever you
specify, unless you explicitly create a different ``Connection`` to use
(described below).
Defaults:
- ``host`` = ``'localhost'``
- ``port`` = ``8125``
- ``sample_rate`` = ``1``
- ``disabled`` = ``False``
Advanced Usage
--------------
>>> import statsd
>>>
>>> # Open a connection to `server` on port `1234` with a `50%` sample rate
>>> statsd_connection = statsd.Connection(
... host='server',
... port=1234,
... sample_rate=0.5,
... )
>>>
>>> # Create a client for this application
>>> statsd_client = statsd.Client(__name__, statsd_connection)
>>>
>>> class SomeClass(object):
... def __init__(self):
... # Create a client specific for this class
... self.statsd_client = statsd_client.get_client(
... self.__class__.__name__)
...
... def do_something(self):
... # Create a `timer` client
... timer = self.statsd_client.get_client(class_=statsd.Timer)
...
... # start the measurement
... timer.start()
...
... # do something
... timer.intermediate('intermediate_value')
...
... # do something else
... timer.stop('total')
If there is a need to turn *OFF* the service and avoid sending UDP messages,
the ``Connection`` class can be disabled by enabling the disabled argument::
>>> statsd_connection = statsd.Connection(
... host='server',
... port=1234,
... sample_rate=0.5,
... disabled=True
... )
If logging's level is set to debug the ``Connection`` object will inform it is
not sending UDP messages anymore.
Raw data
{
"_id": null,
"home_page": "https://github.com/WoLpH/python-statsd",
"name": "python-statsd",
"maintainer": "",
"docs_url": "https://pythonhosted.org/python-statsd/",
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Rick van Hattem",
"author_email": "Wolph@wol.ph",
"download_url": "https://files.pythonhosted.org/packages/bc/ea/0beeadf66faed4ccdcb48009bb4eebf580ac6c05e55b6fae4032c6c45b9a/python-statsd-2.1.0.tar.gz",
"platform": "",
"description": "Introduction\n============\n\n.. image:: https://travis-ci.org/WoLpH/python-statsd.svg?branch=master\n :alt: Test Status\n :target: https://travis-ci.org/WoLpH/python-statsd\n\n.. image:: https://coveralls.io/repos/WoLpH/python-statsd/badge.svg?branch=master\n :alt: Coverage Status\n :target: https://coveralls.io/r/WoLpH/python-statsd?branch=master\n\n`statsd` is a client for Etsy's statsd server, a front end/proxy for the\nGraphite stats collection and graphing server.\n\nLinks\n-----\n\n - The source: https://github.com/WoLpH/python-statsd\n - Project page: https://pypi.python.org/pypi/python-statsd\n - Reporting bugs: https://github.com/WoLpH/python-statsd/issues\n - Documentation: http://python-statsd.readthedocs.io/en/latest/\n - My blog: http://w.wol.ph/\n - Statsd: https://github.com/etsy/statsd\n - Graphite: http://graphite.wikidot.com\n\nInstall\n-------\n\nTo install simply execute `python setup.py install`.\nIf you want to run the tests first, run `python setup.py nosetests`\n\n\nUsage\n-----\n\nTo get started real quick, just try something like this:\n\nBasic Usage\n~~~~~~~~~~~\n\nTimers\n^^^^^^\n\n >>> import statsd\n >>>\n >>> timer = statsd.Timer('MyApplication')\n >>>\n >>> timer.start()\n >>> # do something here\n >>> timer.stop('SomeTimer')\n\n\nCounters\n^^^^^^^^\n\n >>> import statsd\n >>>\n >>> counter = statsd.Counter('MyApplication')\n >>> # do something here\n >>> counter += 1\n\n\nGauge\n^^^^^\n\n >>> import statsd\n >>>\n >>> gauge = statsd.Gauge('MyApplication')\n >>> # do something here\n >>> gauge.send('SomeName', value)\n\n\nRaw\n^^^\n\nRaw strings should be e.g. pre-summarized data or other data that will\nget passed directly to carbon. This can be used as a time and\nbandwidth-saving mechanism sending a lot of samples could use a lot of\nbandwidth (more b/w is used in udp headers than data for a gauge, for\ninstance).\n\n\n\n >>> import statsd\n >>>\n >>> raw = statsd.Raw('MyApplication', connection)\n >>> # do something here\n >>> raw.send('SomeName', value, timestamp)\n\nThe raw type wants to have a timestamp in seconds since the epoch (the\nstandard unix timestamp, e.g. the output of \"date +%s\"), but if you leave it out or\nprovide None it will provide the current time as part of the message\n\nAverage\n^^^^^^^\n\n >>> import statsd\n >>>\n >>> average = statsd.Average('MyApplication', connection)\n >>> # do something here\n >>> average.send('SomeName', 'somekey:%d'.format(value))\n\n\nConnection settings\n^^^^^^^^^^^^^^^^^^^\n\nIf you need some settings other than the defaults for your ``Connection``,\nyou can use ``Connection.set_defaults()``.\n \n >>> import statsd\n >>> statsd.Connection.set_defaults(host='localhost', port=8125, sample_rate=1, disabled=False)\n\nEvery interaction with statsd after these are set will use whatever you\nspecify, unless you explicitly create a different ``Connection`` to use\n(described below).\n\nDefaults:\n\n- ``host`` = ``'localhost'``\n- ``port`` = ``8125``\n- ``sample_rate`` = ``1``\n- ``disabled`` = ``False``\n\n\nAdvanced Usage\n--------------\n\n >>> import statsd\n >>>\n >>> # Open a connection to `server` on port `1234` with a `50%` sample rate\n >>> statsd_connection = statsd.Connection(\n ... host='server',\n ... port=1234,\n ... sample_rate=0.5,\n ... )\n >>>\n >>> # Create a client for this application\n >>> statsd_client = statsd.Client(__name__, statsd_connection)\n >>>\n >>> class SomeClass(object):\n ... def __init__(self):\n ... # Create a client specific for this class\n ... self.statsd_client = statsd_client.get_client(\n ... self.__class__.__name__)\n ...\n ... def do_something(self):\n ... # Create a `timer` client\n ... timer = self.statsd_client.get_client(class_=statsd.Timer)\n ...\n ... # start the measurement\n ... timer.start()\n ...\n ... # do something\n ... timer.intermediate('intermediate_value')\n ...\n ... # do something else\n ... timer.stop('total')\n\nIf there is a need to turn *OFF* the service and avoid sending UDP messages,\nthe ``Connection`` class can be disabled by enabling the disabled argument::\n\n >>> statsd_connection = statsd.Connection(\n ... host='server',\n ... port=1234,\n ... sample_rate=0.5,\n ... disabled=True\n ... )\n\nIf logging's level is set to debug the ``Connection`` object will inform it is\nnot sending UDP messages anymore.\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "statsd is a client for Etsy's node-js statsd server. A proxy for the Graphite stats collection and graphing server.",
"version": "2.1.0",
"project_urls": {
"Homepage": "https://github.com/WoLpH/python-statsd"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6faf224e67da2deda72317aa9afe3445cf849ebd86f4001e20b5d164ef9d05f8",
"md5": "3586ccc9e53371907bbeac6853d7db5d",
"sha256": "f0b8b3333a7d474a3b0ece069e4849febdc66d2712d5290aea6ff1189a05fb80"
},
"downloads": -1,
"filename": "python_statsd-2.1.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "3586ccc9e53371907bbeac6853d7db5d",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 14479,
"upload_time": "2017-09-05T02:02:35",
"upload_time_iso_8601": "2017-09-05T02:02:35.631768Z",
"url": "https://files.pythonhosted.org/packages/6f/af/224e67da2deda72317aa9afe3445cf849ebd86f4001e20b5d164ef9d05f8/python_statsd-2.1.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bcea0beeadf66faed4ccdcb48009bb4eebf580ac6c05e55b6fae4032c6c45b9a",
"md5": "899b5a64d31abd8304660432503a04c3",
"sha256": "d2c573d325d0f015b4d79f0d0f8c88dd8413d7b9ef890c09076a9b6089ab301c"
},
"downloads": -1,
"filename": "python-statsd-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "899b5a64d31abd8304660432503a04c3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10834,
"upload_time": "2017-09-05T02:02:33",
"upload_time_iso_8601": "2017-09-05T02:02:33.536463Z",
"url": "https://files.pythonhosted.org/packages/bc/ea/0beeadf66faed4ccdcb48009bb4eebf580ac6c05e55b6fae4032c6c45b9a/python-statsd-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2017-09-05 02:02:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "WoLpH",
"github_project": "python-statsd",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "python-statsd"
}