{ "info": { "author": "Farzad Ghanei", "author_email": "farzad.ghanei@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: Jython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Networking :: Monitoring" ], "description": "**************\nStatsd Metrics\n**************\n\n.. image:: https://travis-ci.org/farzadghanei/statsd-metrics.svg?branch=master\n :target: https://travis-ci.org/farzadghanei/statsd-metrics\n\n.. image:: https://ci.appveyor.com/api/projects/status/bekwcg8n1xe0w0n9/branch/master?svg=true\n :target: https://ci.appveyor.com/project/farzadghanei/statsd-metrics?branch=master\n\nMetric classes for Statsd, and Statsd clients (each metric in a single request, or send batch requests).\n\nMetric classes represent the data used in Statsd protocol excluding the IO, to create,\nrepresent and parse Statsd requests. So any Statsd server and client regardless of the\nIO implementation can use them to send/receive Statsd requests.\n\nThe library also comes with a rich set of Statsd clients using the same metric classes, and\nPython standard library socket module.\n\n\nMetric Classes\n--------------\n\n* Counter\n* Timer\n* Gauge\n* Set\n* GaugeDelta\n\n.. code-block:: python\n\n from statsdmetrics import Counter, Timer\n\n counter = Counter('event.login', 1, 0.2)\n counter.to_request() # returns event.login:1|c|@0.2\n\n timer = Timer('db.search.username', 27.4)\n timer.to_request() # returns db.search.username:27.4|ms\n\nParse metrics from a Statsd request\n\n.. code-block:: python\n\n from statsdmetrics import parse_metric_from_request\n\n event_login = parse_metric_from_request('event.login:1|c|@.2')\n # event_login is a Counter object with count = 1 and sample_rate = 0.2\n\n mem_usage = parse_metric_from_request('resource.memory:2048|g')\n # mem_usage is a Gauge object with value = 2028\n\nStatsd Clients\n--------------\n* ``client.Client``: Default client, sends request on each call using UDP\n* ``client.BatchClient``: Buffers metrics and flushes them in batch requests using UDP\n* ``client.tcp.TCPClient``: Sends request on each call using TCP\n* ``client.tcp.TCPBatchClient``: Buffers metrics and flushes them in batch requests using TCP\n\nSend Statsd requests\n\n.. code-block:: python\n\n from statsdmetrics.client import Client\n\n # default client, send metrics over UDP\n client = Client(\"stats.example.org\")\n client.increment(\"login\")\n client.decrement(\"connections\", 2)\n client.timing(\"db.search.username\", 3500)\n client.gauge(\"memory\", 20480)\n client.gauge_delta(\"memory\", -256)\n client.set(\"unique.ip_address\", \"10.10.10.1\")\n\n # helpers for timing operations\n chronometer = client.chronometer()\n chronometer.time_callable(\"func1_duration\", func1)\n\n # decorate functions to send timing metrics for the duration of their running time\n @chronometer.wrap(\"func2_duration\")\n def func2():\n pass\n\n # send timing for duration of a with block\n with client.stopwatch(\"with_block_duration\"):\n pass\n\n\n\nSending multiple metrics in batch requests by ``BatchClient``, either\nby using an available client as the context manager:\n\n\n.. code-block:: python\n\n from statsdmetrics.client import Client\n\n client = Client(\"stats.example.org\")\n with client.batch_client() as batch_client:\n batch_client.increment(\"login\")\n batch_client.decrement(\"connections\", 2)\n batch_client.timing(\"db.search.username\", 3500)\n # now all metrics are flushed automatically in batch requests\n\n\nor by creating a ``BatchClient`` object explicitly:\n\n\n.. code-block:: python\n\n from statsdmetrics.client import BatchClient\n\n client = BatchClient(\"stats.example.org\")\n client.set(\"unique.ip_address\", \"10.10.10.1\")\n client.gauge(\"memory\", 20480)\n client.flush() # sends one UDP packet to remote server, carrying both metrics\n\n # timing helpers are available on all clients\n chronometer = client.chronometer()\n chronometer.time_callable(\"func1_duration\", func1)\n\n @chronometer.wrap(\"func2_duration\")\n def func2():\n pass\n\n with client.stopwatch(\"with_block_duration\"):\n pass\n\n client.flush()\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install statsdmetrics\n\n\nThe only dependencies are Python 2.7+ and setuptools.\nCPython 2.7, 3.4+, 3.7-dev, PyPy, and Jython 2.7 are tested)\n\nHowever on development (and test) environment\n`pytest `_, `mock `_ is required (for Python 2),\n`typing `_ is recommended.\n\n.. code-block:: bash\n\n # on dev/test env\n $ pip install -r requirements-dev.txt\n\n\nDevelopment\n-----------\n\n* Code is on `GitHub `_\n* Documentations are on `Read The Docs `_\n\nTests\n^^^^^\n\n`Tox `_ is most convenient to run tests with since it handles creation of virtualenvs\n\n.. code-block:: bash\n\n $ tox\n\nWhen development dependencies are installed (preferably with a virtual environment),\ntests can be run by calling `pytest`.\n\n.. code-block:: bash\n\n $ pytest\n\nIntegration tests are available as part of the test suite, bringing up dummy servers (but actually listening on\nnetwork socket) to capture requests instead of processing them. Then send some metrics and\nassert if the captured requests match the expected.\n\nLicense\n-------\n\nStatsd metrics is released under the terms of the\n`MIT license `_.\n\nThe MIT License (MIT)\n\nCopyright (c) 2015-2018 Farzad Ghanei\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/farzadghanei/statsd-metrics", "keywords": "statsd metrics client", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "statsdmetrics", "package_url": "https://pypi.org/project/statsdmetrics/", "platform": "", "project_url": "https://pypi.org/project/statsdmetrics/", "project_urls": { "Homepage": "https://github.com/farzadghanei/statsd-metrics" }, "release_url": "https://pypi.org/project/statsdmetrics/2.0.2/", "requires_dist": [ "pytest; extra == 'dev'", "mock; extra == 'dev'", "typing; extra == 'dev'" ], "requires_python": "", "summary": "Statsd metrics classes and clients", "version": "2.0.2" }, "last_serial": 4138270, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "02c30b5713c2bb0579321d756d8c300e", "sha256": "2ea8cac2cdd142d9a4d918392d57ca62d6fd26304c622bb04d1e1d8f99b308cc" }, "downloads": -1, "filename": "statsdmetrics-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "02c30b5713c2bb0579321d756d8c300e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8859, "upload_time": "2015-09-26T05:10:27", "url": "https://files.pythonhosted.org/packages/eb/8b/6b62bfb7f06a8446e6b9b41358223fb16034f92c7e70a1076d485e322d85/statsdmetrics-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8e7a00de996cefe49cbabfe71a00c9be", "sha256": "36c549b27fae5355dcdfaf85c178a0831c0836abf87e02ab53174b4628bdbdf2" }, "downloads": -1, "filename": "statsdmetrics-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8e7a00de996cefe49cbabfe71a00c9be", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6293, "upload_time": "2015-09-26T05:10:37", "url": "https://files.pythonhosted.org/packages/9f/b0/00c645b802243aa2ab83660b68ff93bf5206e3f8532da4ec86cf22e0f464/statsdmetrics-0.1.0.tar.gz" } ], "0.2.0": [], "0.2.1": [ { "comment_text": "", "digests": { "md5": "6cfcb70818bcb45d723bb42349e38c3b", "sha256": "109a75c0b14ceb9edae473d8bd7d29d531a0527ca2c37c7b5e0d761ec32da3fe" }, "downloads": -1, "filename": "statsdmetrics-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6cfcb70818bcb45d723bb42349e38c3b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10707, "upload_time": "2015-10-04T07:49:07", "url": "https://files.pythonhosted.org/packages/2d/ba/8d19a333e9f0602e82dd559a2699ac47cffd11bac4d18a6ae44862d03a73/statsdmetrics-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0dce9a32830f80f5a1edf74aa1ab28d2", "sha256": "ba486d79d35ad9804469c94ce8ae41566e2e544be4a893f6b5b0a1c67e9050ba" }, "downloads": -1, "filename": "statsdmetrics-0.2.1.tar.gz", "has_sig": false, "md5_digest": "0dce9a32830f80f5a1edf74aa1ab28d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7536, "upload_time": "2015-10-04T07:49:11", "url": "https://files.pythonhosted.org/packages/0f/6e/8b1b1582275dcada9d8167ed23b54f865584c9b53dc29bd3f52c289501f3/statsdmetrics-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "f17c8f57d1950f0573304c719cd2a18f", "sha256": "93228a239fb3d708527f6ebf154cbc2cf36ed4f099688fc8ab64aa7689c22006" }, "downloads": -1, "filename": "statsdmetrics-0.3.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "f17c8f57d1950f0573304c719cd2a18f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11023, "upload_time": "2015-10-10T09:12:56", "url": "https://files.pythonhosted.org/packages/c0/6f/e9e21a722a8899b4e32afecb54e0fd2ec83ad33adaeb584a553895158993/statsdmetrics-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6ff0a113dfac7b334e57bc26348d7d77", "sha256": "84ccec74b6435489904a257ef57d49d4edcaf4518f4cd87d10a7da2b1a3a455e" }, "downloads": -1, "filename": "statsdmetrics-0.3.0.tar.gz", "has_sig": true, "md5_digest": "6ff0a113dfac7b334e57bc26348d7d77", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7720, "upload_time": "2015-10-10T09:13:14", "url": "https://files.pythonhosted.org/packages/14/bd/29492edfad0fdad271f9e0f637398b93db59520c13507efaa00c99ae1ae2/statsdmetrics-0.3.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "677823fa99c522df32a6213e5ee64cf0", "sha256": "2593dcdb126fca9d6a632f007b9f50801c6a6f790381acbae895e7d0f5b48fb4" }, "downloads": -1, "filename": "statsdmetrics-1.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "677823fa99c522df32a6213e5ee64cf0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 28725, "upload_time": "2016-11-16T19:36:49", "url": "https://files.pythonhosted.org/packages/6e/f6/9fdd7add9317a54779bac6f64d0c343239cab7dc02b160cd284a5c241137/statsdmetrics-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "31ccff193106d70dd3c38d84413357e8", "sha256": "fc8c7d4e234cb7e0d4d08f19626219c667a9736a0018b45e5979a8530c932359" }, "downloads": -1, "filename": "statsdmetrics-1.0.0.tar.gz", "has_sig": true, "md5_digest": "31ccff193106d70dd3c38d84413357e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20705, "upload_time": "2016-11-16T19:37:12", "url": "https://files.pythonhosted.org/packages/8a/98/af9f5206a24045ad91a48dd5cad1d262d0590988ffe6967b2f9611e54251/statsdmetrics-1.0.0.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "86e37d2b55a7dd70821ea04b7d1ca39d", "sha256": "ddab8a4157ce72cf0fe58786e997441bb97d16ec6d9e0bb7caa51fcdf4b94c5a" }, "downloads": -1, "filename": "statsdmetrics-2.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "86e37d2b55a7dd70821ea04b7d1ca39d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 27619, "upload_time": "2018-08-05T19:26:43", "url": "https://files.pythonhosted.org/packages/40/a9/406f77dde22e5e4f295873b4c0c1589258ba837e75f38c193b67d5716b33/statsdmetrics-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c3eec39f1e71c4ce6257defa1fc1dfd", "sha256": "88ffdf8b80b4475b4012b27b6820a2919de99e468c4bd8f37150df6c7e381286" }, "downloads": -1, "filename": "statsdmetrics-2.0.0.tar.gz", "has_sig": true, "md5_digest": "6c3eec39f1e71c4ce6257defa1fc1dfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 65275, "upload_time": "2018-08-05T19:26:59", "url": "https://files.pythonhosted.org/packages/25/8b/45b9091fef3e1b896f67b5f10b56a8e33b6fb024cc4de148c759a94c37aa/statsdmetrics-2.0.0.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "5af47722c7f32e647558c2a70b5b263d", "sha256": "0c03e311c1a05ff89c7c5f5518c46f11b7f7a27f7d2fdc42cf7879782fc81c37" }, "downloads": -1, "filename": "statsdmetrics-2.0.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "5af47722c7f32e647558c2a70b5b263d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11996, "upload_time": "2018-08-05T19:52:53", "url": "https://files.pythonhosted.org/packages/14/1b/e869260d0ed0b3165061751a36d2ab90bdc38c115da325d922b0cc69af6c/statsdmetrics-2.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0290392af746847fc4ddb2d322f2d21", "sha256": "b4b3c20873f53b47c63c715af4f80c6505ccb7f8bc519bcfe57baccc81b555ca" }, "downloads": -1, "filename": "statsdmetrics-2.0.2.tar.gz", "has_sig": true, "md5_digest": "a0290392af746847fc4ddb2d322f2d21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10314, "upload_time": "2018-08-05T19:53:10", "url": "https://files.pythonhosted.org/packages/60/1f/c228752fda1faed017829ab836fec7c02e93f4103f150c15d2bdd24fd35f/statsdmetrics-2.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5af47722c7f32e647558c2a70b5b263d", "sha256": "0c03e311c1a05ff89c7c5f5518c46f11b7f7a27f7d2fdc42cf7879782fc81c37" }, "downloads": -1, "filename": "statsdmetrics-2.0.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "5af47722c7f32e647558c2a70b5b263d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11996, "upload_time": "2018-08-05T19:52:53", "url": "https://files.pythonhosted.org/packages/14/1b/e869260d0ed0b3165061751a36d2ab90bdc38c115da325d922b0cc69af6c/statsdmetrics-2.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a0290392af746847fc4ddb2d322f2d21", "sha256": "b4b3c20873f53b47c63c715af4f80c6505ccb7f8bc519bcfe57baccc81b555ca" }, "downloads": -1, "filename": "statsdmetrics-2.0.2.tar.gz", "has_sig": true, "md5_digest": "a0290392af746847fc4ddb2d322f2d21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10314, "upload_time": "2018-08-05T19:53:10", "url": "https://files.pythonhosted.org/packages/60/1f/c228752fda1faed017829ab836fec7c02e93f4103f150c15d2bdd24fd35f/statsdmetrics-2.0.2.tar.gz" } ] }