{"id":13937084,"url":"https://github.com/WoLpH/python-statsd","last_synced_at":"2025-07-19T22:33:54.676Z","repository":{"id":57457593,"uuid":"1801825","full_name":"wolph/python-statsd","owner":"wolph","description":"Python Client for the Etsy NodeJS Statsd Server","archived":false,"fork":false,"pushed_at":"2019-02-15T17:19:30.000Z","size":117,"stargazers_count":110,"open_issues_count":1,"forks_count":39,"subscribers_count":6,"default_branch":"develop","last_synced_at":"2024-10-12T00:56:43.621Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://readthedocs.org/docs/python-statsd/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wolph.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-25T23:38:03.000Z","updated_at":"2024-09-26T02:42:37.000Z","dependencies_parsed_at":"2022-09-06T01:24:57.915Z","dependency_job_id":null,"html_url":"https://github.com/wolph/python-statsd","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolph%2Fpython-statsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolph%2Fpython-statsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolph%2Fpython-statsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolph%2Fpython-statsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wolph","download_url":"https://codeload.github.com/wolph/python-statsd/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225970913,"owners_count":17553410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-07T23:03:16.179Z","updated_at":"2024-11-27T05:30:50.818Z","avatar_url":"https://github.com/wolph.png","language":"Python","readme":"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    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e timer = statsd.Timer('MyApplication')\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e timer.start()\n    \u003e\u003e\u003e # do something here\n    \u003e\u003e\u003e timer.stop('SomeTimer')\n\n\nCounters\n^^^^^^^^\n\n    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e counter = statsd.Counter('MyApplication')\n    \u003e\u003e\u003e # do something here\n    \u003e\u003e\u003e counter += 1\n\n\nGauge\n^^^^^\n\n    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e gauge = statsd.Gauge('MyApplication')\n    \u003e\u003e\u003e # do something here\n    \u003e\u003e\u003e 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    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e raw = statsd.Raw('MyApplication', connection)\n    \u003e\u003e\u003e # do something here\n    \u003e\u003e\u003e 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    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e average = statsd.Average('MyApplication', connection)\n    \u003e\u003e\u003e # do something here\n    \u003e\u003e\u003e 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    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e 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    \u003e\u003e\u003e import statsd\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # Open a connection to `server` on port `1234` with a `50%` sample rate\n    \u003e\u003e\u003e statsd_connection = statsd.Connection(\n    ...     host='server',\n    ...     port=1234,\n    ...     sample_rate=0.5,\n    ... )\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # Create a client for this application\n    \u003e\u003e\u003e statsd_client = statsd.Client(__name__, statsd_connection)\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e 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    \u003e\u003e\u003e 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","funding_links":[],"categories":["资源列表","Debugging Tools","Python"],"sub_categories":["调试工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWoLpH%2Fpython-statsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWoLpH%2Fpython-statsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWoLpH%2Fpython-statsd/lists"}