{ "info": { "author": "Morgan & Morgan Developers", "author_email": "developers@forthepeople.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "# metrics-python\nMorgan & Morgan wrapper for application metrics instrumentation. \n\n## Installation\n```bash\npip install mm-metrics\n```\n\n## Core API\n#### Increment\nIncrement a counter for a metric.\n\n```increment(metric)```\n\n#### Gauge\nSet the magnitude of a metric to a value\n\n```gauge(metric, value)```\n\n#### Timer\nTime the execution of a task, via either decorator or context manager\n\n```\n# as decorator\n@timer(metric)\n\n# as contextmanager\nwith timer(metric):\n```\n\n## Environment Variables\n| Name | Default | Description |\n| --- | --- | --- |\n| METRICS_DEFAULT_BACKEND | 'metrics.backends.DataDogMetricsBackend' | The dot-notation path to a metrics backend to default to |\n| DD_API_KEY | None | DataDog API Key |\n| DD_APP_KEY | None | DataDog App Key |\n| DD_SERVICE_NAME | None | The name of the current service. If set, every metric will be tagged by this value like 'service:' |\n| DD_SERVICE_PRIORITY | None | The priority of the current service, on a scale of 1-3 with 1 being highest priority. If set, every metric will be tagged by this value like 'priority:' |\n| DD_GLOBAL_TAGS | None | Any additional global tags to apply when metrics are sent. For instance, global tags like 'foobar:1,baz:2' would send tags `['foobar:1', 'baz:2']` with every metric |\n \n## Examples\n\n1. Time the execution of a task\n\n```python\nfrom metrics.decorators import timer\nimport requests\n\n@timer(metric='mm.connections.sf.sync.timer')\ndef sync_to_sf(data):\n resp = requests.post('https://sf-url.com', data=data)\n return resp.ok\n```\n\n2. Increment an error counter when a function hits an error, increment a count counter when a function completes successfully\n\n```python\nfrom metrics.decorators import increment\n\n\n@increment(on_complete_metric='mm.connections.aws.secrets.count', on_error_metric='mm.connections.aws.secrets.errors.count')\ndef secrets():\n # get AWS secrets handle\n return boto3.client('secrets')\n```\n\n3. Send some extra tags to attach to a metric (note: some backends might not support tagging and will simply disregard the parameter)\n\n```python\nfrom metrics.decorators import increment\n\n\n@increment(on_complete_metric='mm.requests.get.count', on_error_metric='mm.connections.get.errors.count', tags=['path:/'])\ndef get(self):\n return HttpResponse(status=200)\n```\n\n## Motivation\nGiven that most client's have similar (and straightforward) requirements for metric tracking,\nwe wrap these common methods (as well as helper tooling) in this abstract Python API. This \ngives us the flexibility to:\n\n* Maintain metric tracking functionality in a central location\n* Decouple metric tracking from core application functionality\n* Swap statsD providers opaquely (e.g DogStatsD -> Vanilla StatsD)\n\n## Additional Reading\n\n* For more detail on metrics collection at MM and metric naming guidelines, see the wiki page [here](https://help.forthepeople.com/index.php/Engineering_and_Platform/Metrics_Monitoring_and_Alerting#Log_Collection)", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Morgan-and-Morgan/metrics-python/", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "mm-metrics", "package_url": "https://pypi.org/project/mm-metrics/", "platform": "", "project_url": "https://pypi.org/project/mm-metrics/", "project_urls": { "Homepage": "https://github.com/Morgan-and-Morgan/metrics-python/" }, "release_url": "https://pypi.org/project/mm-metrics/0.6.0/", "requires_dist": null, "requires_python": "", "summary": "Python client library abstracting away metrics collection", "version": "0.6.0" }, "last_serial": 4531487, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "c6da06c052e4adf1771dc9e72a973787", "sha256": "2879a647df8d398b879ffbba5ddf778a5f40edcb7b5e0f24a56cb2377ebae309" }, "downloads": -1, "filename": "mm_metrics-0.1.2.tar.gz", "has_sig": false, "md5_digest": "c6da06c052e4adf1771dc9e72a973787", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3379, "upload_time": "2018-11-12T20:11:43", "url": "https://files.pythonhosted.org/packages/ea/88/8f600b0cece97a2fafbc2cbf3db86e1e453a1b88f197d52befe872aa8f5f/mm_metrics-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "77da4f101ae665c1049f667b8119641d", "sha256": "7a0d1c58a3fa4432510060a352d98199fa18b0f559711ab3b4c0fba2213bd313" }, "downloads": -1, "filename": "mm_metrics-0.2.0.tar.gz", "has_sig": false, "md5_digest": "77da4f101ae665c1049f667b8119641d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3437, "upload_time": "2018-11-12T21:45:25", "url": "https://files.pythonhosted.org/packages/fe/e9/b18495957679a9edd1fd1e82676bc29d8a0120e333f8bd5a95fca353526d/mm_metrics-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "697ff205a1880fee1a56b2c98c0ead7f", "sha256": "c682c952dc5434f61dc02f32356ed31b92d9bc61239fc3627a6b2c8a06ef41f5" }, "downloads": -1, "filename": "mm_metrics-0.2.1.tar.gz", "has_sig": false, "md5_digest": "697ff205a1880fee1a56b2c98c0ead7f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3467, "upload_time": "2018-11-12T21:49:07", "url": "https://files.pythonhosted.org/packages/3d/fd/2f2c69752663198cdeed21b4999bddcb2f0ef60e6a0654d6036856911265/mm_metrics-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b1405ae3ff30e1a13f50b6b9ad2ce694", "sha256": "f8af50519db55b6f831736afcbd58a8bd8c571d0d79edbc86a4825c1696fe745" }, "downloads": -1, "filename": "mm_metrics-0.3.0.tar.gz", "has_sig": false, "md5_digest": "b1405ae3ff30e1a13f50b6b9ad2ce694", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3899, "upload_time": "2018-11-16T16:54:48", "url": "https://files.pythonhosted.org/packages/47/30/a09385d8f40e9b52ef2caecc9be491e142689b1b6bca56bdb1443bec18e7/mm_metrics-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "9be1a891a48794ba9b725adfab96ad69", "sha256": "125492de6f5491dbaf0fef50d0ac921ae58c17dcba34c4d97f9718b89377b7d5" }, "downloads": -1, "filename": "mm_metrics-0.4.0.tar.gz", "has_sig": false, "md5_digest": "9be1a891a48794ba9b725adfab96ad69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4513, "upload_time": "2018-11-20T18:53:30", "url": "https://files.pythonhosted.org/packages/7b/7b/fb0ae0294c47b4e3bfdf138797d3d2930dbfe26b809b541bebdd0d036af1/mm_metrics-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "3647892dd98d69958d6e9cf17330b357", "sha256": "8bade2725815ec1d405f799e066629ac3d17df53ce046e4b878a3ea1d9765297" }, "downloads": -1, "filename": "mm_metrics-0.5.0.tar.gz", "has_sig": false, "md5_digest": "3647892dd98d69958d6e9cf17330b357", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4550, "upload_time": "2018-11-20T19:52:50", "url": "https://files.pythonhosted.org/packages/63/d9/3174e84eedc7e4ab69b7d81929291added55772ccfb0905f121045083fac/mm_metrics-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "430f9241f11177a77e10104dc9523233", "sha256": "c2621a6a259da8fbe71a7d933f8e90d28e3fc5e63c401b4c5b35240d1952ef6a" }, "downloads": -1, "filename": "mm_metrics-0.5.1.tar.gz", "has_sig": false, "md5_digest": "430f9241f11177a77e10104dc9523233", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4591, "upload_time": "2018-11-20T21:05:14", "url": "https://files.pythonhosted.org/packages/8a/e7/06ad4582edf36b30e067720272d74d3a3382a3d6e62d0058922067bd9633/mm_metrics-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "845e1abf645ba51c02a50b5a3364f5a1", "sha256": "864873dc69a9cfdb24d91b90562d9a3aaf423e1b7589bd297515a6956014b5da" }, "downloads": -1, "filename": "mm_metrics-0.5.2.tar.gz", "has_sig": false, "md5_digest": "845e1abf645ba51c02a50b5a3364f5a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4613, "upload_time": "2018-11-21T21:19:16", "url": "https://files.pythonhosted.org/packages/85/12/107708a6bc16c1d2f8e2db7d2ec1f7283eb8246e9e2216a4cdd9a117184d/mm_metrics-0.5.2.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "02d294dc49963ffce653ffa0edbba348", "sha256": "6971f9f7722702fd1d121b2a1496ea5128eee65015603b2db3102725b97fb5b1" }, "downloads": -1, "filename": "mm_metrics-0.6.0.tar.gz", "has_sig": false, "md5_digest": "02d294dc49963ffce653ffa0edbba348", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5478, "upload_time": "2018-11-26T22:34:31", "url": "https://files.pythonhosted.org/packages/4d/fa/d6208615429afb6a4ec2a0e01f1c1b09811735cdb3a9393fcf7b828477b8/mm_metrics-0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "02d294dc49963ffce653ffa0edbba348", "sha256": "6971f9f7722702fd1d121b2a1496ea5128eee65015603b2db3102725b97fb5b1" }, "downloads": -1, "filename": "mm_metrics-0.6.0.tar.gz", "has_sig": false, "md5_digest": "02d294dc49963ffce653ffa0edbba348", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5478, "upload_time": "2018-11-26T22:34:31", "url": "https://files.pythonhosted.org/packages/4d/fa/d6208615429afb6a4ec2a0e01f1c1b09811735cdb3a9393fcf7b828477b8/mm_metrics-0.6.0.tar.gz" } ] }