{ "info": { "author": "Gaelen Hadlett", "author_email": "gaelenh@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: System :: Logging" ], "description": "Python StatsD Client\n====================\n\n`StatsD `_ is a stats server that plays\nwith `Graphite `_. Together, they collect,\naggregate, and show stats. If you don't know what either of those are,\nwell, why are you still reading this? If you write software or know\nsomeone that does, I bet collecting stats will make your software\nbetter, or at the very least give you something to look at and think\nabout. StatsD makes it really easy to send stats within your code. This\nclient maks it even easier to get stats out of your python code.\n\nInstall\n-------\n\nAnnoyed with managing external packages? There are plenty of statsd\nclients that come up under 'pip search statsd'. Who has time to keep\ntrack of tiny dependencies for small projects? Just copy statsd.py into\nyour project if you're into that kind of thing. No need to depend on\nsome multi-file package for what should be a simple client. Grab and Go!\nIf you're a stickler for dependencies, you probably don't need to know\nhow to install this, but here you go any how:\n\nClone and install:\n\n::\n\n git clone git@github.com:gaelenh/python-statsd-client.git\n cd python-statsd-client\n python setup.py install\n\nInstall with pip:\n\n::\n\n pip install statsd-client\n\nOr like I said above, just copy statsd.py into your code base.\n\nUsage\n-----\n\nBasic\n~~~~~\n\nSetup is easy. By default, the client will connect to localhost on the\ndefault statsd port (8125).\n\n::\n\n import statsd\n statsd.incr('processed') # Increment processed bucket by 1\n statsd.incr('processed', 5) # This time by 5\n statsd.incr('processed', sample_rate=0.9) # Increment with a sample rate of .9\n statsd.timing('pipeline', 2468.34) # Pipeline took 2468.34 ms to execute\n\nWant to connect to a non-local statsd? Use\nstatsd.init\\_statsd(settings). Settings is a dict with any of these\nkeys:\n\n::\n\n STATSD_HOST (Default 'localhost'): String host name.\n STATSD_PORT (Default 8125): Integer port number.\n STATSD_SAMPLE_RATE (Default None (same as 1.0)): Integer/Float between 0 and 1.\n STATSD_BUCKET_PREFIX (Default None): String prefix added to all buckets. The code will handle dotting them together.\n\nIf you do not want to use init\\_statsd, you can always pass in your\nsettings when you create the clients, timers or counters:\n\n::\n\n from statsd import StatsdClient\n client = StatsdClient(host='127.0.0.1', port=9999, prefix='app', sample_rate=0.9)\n\nCounters\n~~~~~~~~\n\nWant to count things? Use StatsdCounter:\n\n::\n\n import statsd\n statsd.init_statsd({'STATSD_BUCKET_PREFIX': 'photos'})\n counter = statsd.StatsdCounter('processed')\n # calls on counter will send updates to bucket named 'photos.processed'\n counter += 1 # equivalent to counter.incr() or counter.incr(1)\n counter += 5 # equivalent to counter.incr(5)\n counter -= 10 # equivalent to counter.decr(10)\n\nTiming\n~~~~~~\n\nInterested in timing? Check out all the ways you can time things:\n\n::\n\n import statsd\n statsd.init_statsd({'STATSD_BUCKET_PREFIX': 'photos'})\n timer = statsd.StatsdTimer('pipeline')\n timer.start()\n # Do stuff\n timer.split('stage1') # Sends timing data for bucket 'photos.pipeline.stage1'\n # Do more stuff\n timer.split('stage2') # Sends timing data for bucket 'photos.pipeline.stage2'\n # Do even more stuff\n timer.stop() # Sends timing data for bucket 'photos.pipeline.total'\n\nTimers can be used as decorators too:\n\n::\n\n from statsd import StatsdTimer\n @StatsdTimer.wrap('pipeline')\n def process():\n pass\n process() # Sends timing data for bucket 'pipeline.total'\n\nFancy with statement usage!\n\n::\n\n from statsd import StatsdTimer\n with StatsdTimer('photos'):\n pass # Do stuff\n\nEven fancier:\n\n::\n\n from statsd import StatsdTimer\n with StatsdTimer('photos') as t:\n # Do stuff\n t.split('stage1')\n # Do more stuff\n t.split('stage2')\n # Finish up\n\nUsing timers with decorators or the with statement will still sends\nstats if an exception is raised in the code block:\n\n::\n\n from statsd import StatsdTimer\n class Foo(object):\n @StatsdTimer('photos')\n def proc(self):\n # Do stuff\n raise ValueError('Whoops')\n f = Foo()\n f.proc() # Raises exception, but sends timing data for bucket 'photos.total-except'\n\nMisc\n----\n\nThe client integrates great with `Flask `_.\nJust call statsd.init\\_statsd when you're initializing all your other\nframework components. Once that's done, you can use the timers and\ncounters anywhere in your code.\n\nContributing\n------------\n\nIf you find a bug and want to fix it, fork, branch, and submit a pull\nrequest. The master branch will always have the latest working code.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gaelenh/python-statsd-client", "keywords": "statsd,graphite,stats", "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "statsd-client", "package_url": "https://pypi.org/project/statsd-client/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/statsd-client/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/gaelenh/python-statsd-client" }, "release_url": "https://pypi.org/project/statsd-client/1.0.6/", "requires_dist": null, "requires_python": null, "summary": "StatsD client for Python", "version": "1.0.6" }, "last_serial": 3084908, "releases": { "1.0.2": [ { "comment_text": "", "digests": { "md5": "4cb9d9f0d0c3e97071c210343f72c64e", "sha256": "f50cef28f4e82fa5d8a899bef2e61d0bb498cfcd1489f0e4aab2394d844cc556" }, "downloads": -1, "filename": "statsd-client-1.0.2.tar.gz", "has_sig": false, "md5_digest": "4cb9d9f0d0c3e97071c210343f72c64e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4487, "upload_time": "2012-11-19T17:44:50", "url": "https://files.pythonhosted.org/packages/0d/b9/3d0ae37b874c43649bef8f505db3b47ada1ebd5629258381606fe8dd9984/statsd-client-1.0.2.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "7b58072cb58b05ba8aa9e2adea5fcf1c", "sha256": "78b4e41b18d1d45d549a48dab9a2e407e9f7a71014e9a9b28f9ec9e934ce6250" }, "downloads": -1, "filename": "statsd-client-1.0.4.tar.gz", "has_sig": false, "md5_digest": "7b58072cb58b05ba8aa9e2adea5fcf1c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4641, "upload_time": "2013-02-14T04:25:41", "url": "https://files.pythonhosted.org/packages/72/f4/b645e1a9f761b1944587d1cd70a54a5cc504f61dbaffdd2b1fb8a9adefcd/statsd-client-1.0.4.tar.gz" } ], "1.0.5": [], "1.0.6": [ { "comment_text": "", "digests": { "md5": "eb122f12c950fc8c9e8777e37ea68d78", "sha256": "925c17f59cccf17b7919c9b00aab5ada36355d78752f2434ff054eeafbd89997" }, "downloads": -1, "filename": "statsd-client-1.0.60.tar.gz", "has_sig": false, "md5_digest": "eb122f12c950fc8c9e8777e37ea68d78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4604, "upload_time": "2017-08-09T19:18:06", "url": "https://files.pythonhosted.org/packages/27/b6/4f051ae8faf234a9b889f6fefb68ac739922747da92a7a3778466787b3d0/statsd-client-1.0.60.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb122f12c950fc8c9e8777e37ea68d78", "sha256": "925c17f59cccf17b7919c9b00aab5ada36355d78752f2434ff054eeafbd89997" }, "downloads": -1, "filename": "statsd-client-1.0.60.tar.gz", "has_sig": false, "md5_digest": "eb122f12c950fc8c9e8777e37ea68d78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4604, "upload_time": "2017-08-09T19:18:06", "url": "https://files.pythonhosted.org/packages/27/b6/4f051ae8faf234a9b889f6fefb68ac739922747da92a7a3778466787b3d0/statsd-client-1.0.60.tar.gz" } ] }