{ "info": { "author": "Mark Story", "author_email": "markstory@freshbooks.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7" ], "description": "# Statsdecor\n\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)\n[![Build Status](https://api.travis-ci.org/freshbooks/statsdecor.svg)](https://travis-ci.org/freshbooks/statsdecor)\n\nA set of decorators and helper methods for adding statsd metrics to applications.\n\n## Installation\n\nYou can use pip to install statsdecor:\n\n```shell\npip install statsdecor\n```\n\n## Configuration\n\nYou must use `statsdecor.configure` to configure the internal statsd client before\ncalling other methods:\n\n```python\nimport statsdecor\n\nstatsdecor.configure(host='localhost', prefix='superapp.')\n```\n\nConfiguration is generally setup during your application's bootstrap. Once\nset configuration values are re-used in all clients that `statsdecor` creates.\n\n\n## Usage\n\nYou can track metrics with either the module functions, or decorators. Incrementing\nand decrementing counters looks like:\n\n### Metric functions\n\n```python\nimport statsdecor\n\nstatsdecor.incr('save.succeeded')\nstatsdecor.decr('attempts.remaining')\nstatsdecor.gauge('sessions.active', 9001)\n```\n\nCounters and timers can also be set through decorators:\n\n```python\nimport statsdecor.decorators as stats\n\n@stats.increment('save.succeeded')\ndef save(self):\n pass\n\n@stats.decrement('attempts.remaining')\ndef attempt():\n pass\n\n@stats.timed('api_request.duration')\ndef perform_request(self, req)\n pass\n```\n\nWhen using decorators, metrics are only tracked if the decorated function\ndoes not raise an error.\n\n### Context\n\nStatsdecor includes a context manager that can help measure latency and volume\nwhile using metric tags to classify their success & failure. For example,\nsuppose you are making a call to a remote service and wish to write a wrapper\nthat collects latency, volume and failure metrics.\n\nWith our knowledge about how the client library indicates errors we can make a context manager\nbased on StatsContext:\n\n```\nfrom statsdecor.context import StatsContext\n\nclass FoobarClientMetrics(StatsContext):\n def __init__(self, tags=None):\n tags = list(tags or [])\n tags += ['caller:example_1']\n super(ThingyStatsContext, self).__self__('thingy_client', tags=tags)\n\n def exit_hook(self, exc_type, exc_val, exc_tb):\n if exc_val is not None:\n self.add_tags('result:failure')\n else:\n self.add_tags('result:success')\n\n # Bonus: since we have the exception, classify the error type\n if isinstance(exc_val, PermissionDenied):\n self.add_tags('error:permissiondenied')\n elif isinstance(exc_val, TimeOut):\n self.add_tags('error:timeout')\n elif exc_val is not None:\n self.add_tags('error:exception')\n\n```\n\nNow writing wrapper functions with metrics is simple:\n\n```\ndef foobar_get_clients(**args):\n with FoobarClientMetrics(tags=['method:get_clients']) as stats:\n result = call_foobar_get_client(**args)\n\n # We know all foo methods return result['status_code'] so let's\n # add a status_code tag!\n stats.add_tags('status_code:{}'.format(result[\"status_code\"]'))\n return result\n\ndef foobar_add_client(**args):\n with FoobarClientMetrics(tags=['method:add_client']) as stats:\n result = call_foobar_add_client(**args)\n stats.add_tags('status_code:{}'.format(result[\"status_code\"]'))\n return result\n```\n\nNow we can graph:\n\n* volume of calls grouped by the `method` tag\n* average response time, excluding errors (timeouts will no longer skew the average)\n* volume of errors grouped by method, and/or type\n\n# Development\n\n## Testing and coverage\n\n```\nmake test\nmake coverage\n```\n\nYou can track metrics with either the module functions, or decorators. Incrementing\n\n## Releasing\n\nstatsdecor uses [semver](https://semver.org) for version numbers. Before tagging,\ncheck for all changes since the last tag for breaking changes, new features,\nand/or bugfixes.\n\n1. edit VERSION\n2. commit/pr/merge bump to VERSION\n3. `make tag`\n\n\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/freshbooks/statsdecor", "keywords": "statsd,stats", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "statsdecor", "package_url": "https://pypi.org/project/statsdecor/", "platform": "", "project_url": "https://pypi.org/project/statsdecor/", "project_urls": { "Homepage": "https://github.com/freshbooks/statsdecor" }, "release_url": "https://pypi.org/project/statsdecor/0.4.0/", "requires_dist": [ "statsd", "datadog" ], "requires_python": "", "summary": "A set of decorators and helper methods for adding statsd metrics to applications.", "version": "0.4.0" }, "last_serial": 5512280, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "fc96cb6155ad6c7154c42cde8af32939", "sha256": "ec3b5e603073183eb30800f841fcacf77ebfbf65801e92bb2fdd258ce7961138" }, "downloads": -1, "filename": "statsdecor-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fc96cb6155ad6c7154c42cde8af32939", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4528, "upload_time": "2015-11-09T03:34:05", "url": "https://files.pythonhosted.org/packages/ab/3a/e7943ac34560d8bfdc13311c014cea9ff1643b80ebae659e10c0a92d22fa/statsdecor-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "693b40629c75eb20b1c4889983079dfd", "sha256": "7896bfd298cfbea9ba5e5166e256d8b899b9bfd21786d1d34cbeb599468b627b" }, "downloads": -1, "filename": "statsdecor-0.1.0.tar.gz", "has_sig": false, "md5_digest": "693b40629c75eb20b1c4889983079dfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2728, "upload_time": "2015-11-09T03:33:49", "url": "https://files.pythonhosted.org/packages/34/f7/d62958bca04577b74837846c10d7adc8103dd72df3ab3a379c47fcd62c41/statsdecor-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "fff1a1343b12d1cdfe7b0f7ceba9fab9", "sha256": "d53a7a9db7f6c23643a989bac5a305f4e719b0143e2bbac33accdb3b1d1bb1e9" }, "downloads": -1, "filename": "statsdecor-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fff1a1343b12d1cdfe7b0f7ceba9fab9", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4832, "upload_time": "2016-11-14T21:08:13", "url": "https://files.pythonhosted.org/packages/77/88/5806acff1cfc3077c1cdedef40d17025e82861adc168517b2f368c3ec644/statsdecor-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc925fb7aafc5f2d85b6e2145aec38b0", "sha256": "d8055ad728b9ead5f2296cf58534d6ac77d085f829f53dd083b5062342144a20" }, "downloads": -1, "filename": "statsdecor-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fc925fb7aafc5f2d85b6e2145aec38b0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2906, "upload_time": "2016-11-14T21:08:25", "url": "https://files.pythonhosted.org/packages/4c/47/ee1d1561820491ada7ca94d6fbd72f8dda41c8be72d910736a49fbb2da5b/statsdecor-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "c7109ba3402c2d36554229e067e074e7", "sha256": "8eb7d442d0372fceb3c7426c120c8b1d1dd3812fc3dd99656bb712cc4719e1ba" }, "downloads": -1, "filename": "statsdecor-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c7109ba3402c2d36554229e067e074e7", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4859, "upload_time": "2017-02-22T18:16:25", "url": "https://files.pythonhosted.org/packages/a5/92/beb9d7ee4806c2c1c0216cc0be48bbd22a895a0d672a5b2c6fa4adfc6b0f/statsdecor-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "30617e391248c65b509637c599de5c93", "sha256": "256f11465fedcd604cb0275bf51fdb593f483ead028aa85e09bf794c0816dcad" }, "downloads": -1, "filename": "statsdecor-0.3.0.tar.gz", "has_sig": false, "md5_digest": "30617e391248c65b509637c599de5c93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2936, "upload_time": "2017-02-22T18:16:37", "url": "https://files.pythonhosted.org/packages/d6/6c/f85cf5339da82b25e6458d443122ff9e610db8d11b9dff94dea7bc399af4/statsdecor-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "ed2e4c5504b45ef9635a97becf9311a1", "sha256": "8ceb3dfb26e1c24abeb4941eb031a939e8019a6f380341dec3b06be5c255f7fa" }, "downloads": -1, "filename": "statsdecor-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ed2e4c5504b45ef9635a97becf9311a1", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4904, "upload_time": "2017-03-07T02:38:50", "url": "https://files.pythonhosted.org/packages/2f/59/7969923a862e52eae2cef22d8f56d8972b7e9efbad02bf07dccf49372dd6/statsdecor-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "67e9e463b2f8cb88f77de74032382a49", "sha256": "d88230c9629f081890e9ee31fb941ba9a5ea357b0357772a937f5eab386e93cf" }, "downloads": -1, "filename": "statsdecor-0.3.1.tar.gz", "has_sig": false, "md5_digest": "67e9e463b2f8cb88f77de74032382a49", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2948, "upload_time": "2017-03-07T02:38:48", "url": "https://files.pythonhosted.org/packages/4d/2b/77dc85799af39a9328be3dc5069eb8844b7bce897682ebdc675b4e2559f7/statsdecor-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "6c04528469b0af6f7b6b30312ccfaa7a", "sha256": "10c3a07d6d244b176f97a3b6d11cb6269f8b4f66e818769b2e59e220f68234e3" }, "downloads": -1, "filename": "statsdecor-0.3.2.tar.gz", "has_sig": false, "md5_digest": "6c04528469b0af6f7b6b30312ccfaa7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3684, "upload_time": "2018-05-03T19:13:45", "url": "https://files.pythonhosted.org/packages/ac/6f/38e31786b1efa0bfb73168cc1d8fa5635963ab5db40375e34168af7ccfce/statsdecor-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "5ce39c070510e0a9ba69391edd319154", "sha256": "22774cbc02fc3e940aa4d0badc9d2af9049b2cb417e672bec5ea8ac80909912a" }, "downloads": -1, "filename": "statsdecor-0.3.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5ce39c070510e0a9ba69391edd319154", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4128, "upload_time": "2018-05-03T20:24:21", "url": "https://files.pythonhosted.org/packages/91/9f/a166f861e94bbc517b37674ba366c69f0dbd06cd2d1a720a1b52d232a024/statsdecor-0.3.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c5ee4bf4fcdd059c2440c7aca557950", "sha256": "0d10ada1ea5f20add4769aa46b2732dc4c029d713a6753d3cc03bd761cb3d2ee" }, "downloads": -1, "filename": "statsdecor-0.3.3.tar.gz", "has_sig": false, "md5_digest": "6c5ee4bf4fcdd059c2440c7aca557950", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6197, "upload_time": "2018-05-03T20:24:19", "url": "https://files.pythonhosted.org/packages/b5/ef/9c07ffb1da5dbe2890c9ee802c42103a6ffb388455e62dbd7287ba56153d/statsdecor-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "c4b0c2bd58a2d1460ba491631db67a6a", "sha256": "4bd6eee5d502f4341a949bb7fbcd1a8dfaf36ff75df9bac4e42b1d380f778089" }, "downloads": -1, "filename": "statsdecor-0.3.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c4b0c2bd58a2d1460ba491631db67a6a", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4138, "upload_time": "2018-05-04T18:43:21", "url": "https://files.pythonhosted.org/packages/b6/03/001c24c82542885d36c05d394bc11346e2477acd85512ee580b48ed27fdc/statsdecor-0.3.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "13d2adeb559b94aa5f47171cfb7c65b6", "sha256": "0e3fa88d686806082b5e00e98956331cbafc2ebb9b5b7b5d5eefd454ba90f57f" }, "downloads": -1, "filename": "statsdecor-0.3.4.tar.gz", "has_sig": false, "md5_digest": "13d2adeb559b94aa5f47171cfb7c65b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6254, "upload_time": "2018-05-04T18:43:19", "url": "https://files.pythonhosted.org/packages/a9/51/13cf6530c06691385d41e07bfb2e8a1633aaf18705b3be2123569b05b920/statsdecor-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "5fcc572834a3d5122b540595ef378cfe", "sha256": "f0542d25175bf382257eb5733d80e695e982b4a49b4f1a7b4dcaeafef22456dd" }, "downloads": -1, "filename": "statsdecor-0.3.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5fcc572834a3d5122b540595ef378cfe", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 4148, "upload_time": "2018-07-25T18:51:50", "url": "https://files.pythonhosted.org/packages/e3/c6/8e019466f1d8edb46c51fe49913ccd2446edd8626622be0eab433e965f6c/statsdecor-0.3.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7cbe8e5e0ef4d65f63be945d89f06a1d", "sha256": "2feca4dbd4414f1cae6bc9c9c3f37c840f5ebf6ee0dfbbfee55fbb5c7fdbb82c" }, "downloads": -1, "filename": "statsdecor-0.3.5.tar.gz", "has_sig": false, "md5_digest": "7cbe8e5e0ef4d65f63be945d89f06a1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6624, "upload_time": "2018-07-25T18:51:48", "url": "https://files.pythonhosted.org/packages/e1/ea/d97d0849cda1e1eeff96628911e5534ac187d960eabcb66ad89db038e587/statsdecor-0.3.5.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "c58318445720a5be977ab7f15487ae65", "sha256": "6231d7691fbc22d379c4acbe7224010d085fdef8adbc1c18cb145fb2f819a0a1" }, "downloads": -1, "filename": "statsdecor-0.3.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c58318445720a5be977ab7f15487ae65", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4917, "upload_time": "2019-04-10T18:47:24", "url": "https://files.pythonhosted.org/packages/2e/05/61d8906e1363b6fe26cfd5772f8f3e15c729677c1117c1f80ef4f9f7be26/statsdecor-0.3.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "37d072f1af190cc0a768fda817980dc2", "sha256": "ce40d6a479109583efdbf061f8d58394bb18cc8f2eec576f55b78aab36410129" }, "downloads": -1, "filename": "statsdecor-0.3.6.tar.gz", "has_sig": false, "md5_digest": "37d072f1af190cc0a768fda817980dc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6545, "upload_time": "2019-04-10T18:47:22", "url": "https://files.pythonhosted.org/packages/c9/a6/6b7c618e82d87a11287bef69b77d5ecfb794ba9352dc3babca7f83edf9eb/statsdecor-0.3.6.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "8e10aab3862c07cf81fe1d4016def9e4", "sha256": "f902489a893f51381a389eb95808507311207ff422264bfbc6ad27a6ab53e09d" }, "downloads": -1, "filename": "statsdecor-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e10aab3862c07cf81fe1d4016def9e4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7405, "upload_time": "2019-07-10T13:59:48", "url": "https://files.pythonhosted.org/packages/6a/97/3ac03741bacbde598180fbdf928d33343771cbca38d4c58581083fc609d4/statsdecor-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9e466f1816e987029352e01638e50b95", "sha256": "9d44071a77f5d793825228cc5702bc9ce92865a0d4679713ef5cab9196add223" }, "downloads": -1, "filename": "statsdecor-0.4.0.tar.gz", "has_sig": false, "md5_digest": "9e466f1816e987029352e01638e50b95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9324, "upload_time": "2019-07-10T13:59:49", "url": "https://files.pythonhosted.org/packages/7c/a5/8942c1277527918835579006b1ad5bf803549c0752f9ba87b552de25466f/statsdecor-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8e10aab3862c07cf81fe1d4016def9e4", "sha256": "f902489a893f51381a389eb95808507311207ff422264bfbc6ad27a6ab53e09d" }, "downloads": -1, "filename": "statsdecor-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e10aab3862c07cf81fe1d4016def9e4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7405, "upload_time": "2019-07-10T13:59:48", "url": "https://files.pythonhosted.org/packages/6a/97/3ac03741bacbde598180fbdf928d33343771cbca38d4c58581083fc609d4/statsdecor-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9e466f1816e987029352e01638e50b95", "sha256": "9d44071a77f5d793825228cc5702bc9ce92865a0d4679713ef5cab9196add223" }, "downloads": -1, "filename": "statsdecor-0.4.0.tar.gz", "has_sig": false, "md5_digest": "9e466f1816e987029352e01638e50b95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9324, "upload_time": "2019-07-10T13:59:49", "url": "https://files.pythonhosted.org/packages/7c/a5/8942c1277527918835579006b1ad5bf803549c0752f9ba87b552de25466f/statsdecor-0.4.0.tar.gz" } ] }