Openstack Monasca Statsd
========================
.. image:: https://governance.openstack.org/tc/badges/monasca-statsd.svg
:target: https://governance.openstack.org/tc/reference/tags/index.html
A Monasca-Statsd Python Client.
===============================
Quick Start Guide
-----------------
First install the library with ``pip`` or ``easy_install``:
::
# Install in system python ...
sudo pip install monasca-statsd
# .. or into a virtual env
pip install monasca-statsd
Then start instrumenting your code:
::
# Import the module.
import monascastatsd as mstatsd
# Create the connection
conn = mstatsd.Connection(host='localhost', port=8125)
# Create the client with optional dimensions
client = mstatsd.Client(connection=conn, dimensions={'env': 'test'})
NOTE: You can also create a client without specifying the connection and it will create the client
with the default connection information for the monasca-agent statsd processor daemon
which uses host='localhost' and port=8125.
client = mstatsd.Client(dimensions={'env': 'test'})
# Increment and decrement a counter.
counter = client.get_counter(name='page.views')
counter.increment()
counter += 3
counter.decrement()
counter -= 3
# Record a gauge 50% of the time.
gauge = client.get_gauge('gauge', dimensions={'env': 'test'})
gauge.send('metric', 123.4, sample_rate=0.5)
# Sample a histogram.
histogram = client.get_histogram('histogram', dimensions={'test': 'True'})
histogram.send('metric', 123.4, dimensions={'color': 'red'})
# Time a function call.
timer = client.get_timer()
@timer.timed('page.render')
def render_page():
# Render things ...
pass
# Time a block of code.
timer = client.get_timer()
with timer.time('t'):
# Do stuff
time.sleep(2)
# Add dimensions to any metric.
histogram = client.get_histogram('my_hist')
histogram.send('query.time', 10, dimensions = {'version': '1.0', 'environment': 'dev'})
Feedback
--------
To suggest a feature, report a bug, or participate in the general
discussion, head over to `StoryBoard`_.
License
-------
See LICENSE file. Code was originally forked from Datadog’s
dogstatsd-python, hence the dual license.
.. _StoryBoard: https://storyboard.openstack.org/#!/project/872
Raw data
{
"_id": null,
"home_page": "https://opendev.org/openstack/monasca-statsd",
"name": "monasca-statsd",
"maintainer": "monasca",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "monasca@lists.launchpad.net",
"keywords": "openstack,monitoring,statsd",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/36/5d/1d4e4cae5f4440b54e94729924eb1e72bff2028b3f9b81ff324253b18e22/monasca-statsd-2.7.0.tar.gz",
"platform": null,
"description": "Openstack Monasca Statsd\n========================\n\n.. image:: https://governance.openstack.org/tc/badges/monasca-statsd.svg\n :target: https://governance.openstack.org/tc/reference/tags/index.html\n\nA Monasca-Statsd Python Client.\n===============================\n\nQuick Start Guide\n-----------------\n\nFirst install the library with ``pip`` or ``easy_install``:\n\n::\n\n # Install in system python ...\n sudo pip install monasca-statsd\n\n # .. or into a virtual env\n pip install monasca-statsd\n\nThen start instrumenting your code:\n\n::\n\n # Import the module.\n import monascastatsd as mstatsd\n\n # Create the connection\n conn = mstatsd.Connection(host='localhost', port=8125)\n\n # Create the client with optional dimensions\n client = mstatsd.Client(connection=conn, dimensions={'env': 'test'})\n\n NOTE: You can also create a client without specifying the connection and it will create the client\n with the default connection information for the monasca-agent statsd processor daemon\n which uses host='localhost' and port=8125.\n\n client = mstatsd.Client(dimensions={'env': 'test'})\n\n # Increment and decrement a counter.\n counter = client.get_counter(name='page.views')\n\n counter.increment()\n counter += 3\n\n counter.decrement()\n counter -= 3\n\n # Record a gauge 50% of the time.\n gauge = client.get_gauge('gauge', dimensions={'env': 'test'})\n\n gauge.send('metric', 123.4, sample_rate=0.5)\n\n # Sample a histogram.\n histogram = client.get_histogram('histogram', dimensions={'test': 'True'})\n\n histogram.send('metric', 123.4, dimensions={'color': 'red'})\n\n # Time a function call.\n timer = client.get_timer()\n\n @timer.timed('page.render')\n def render_page():\n # Render things ...\n pass\n\n # Time a block of code.\n timer = client.get_timer()\n\n with timer.time('t'):\n # Do stuff\n time.sleep(2)\n\n # Add dimensions to any metric.\n histogram = client.get_histogram('my_hist')\n histogram.send('query.time', 10, dimensions = {'version': '1.0', 'environment': 'dev'})\n\nFeedback\n--------\n\nTo suggest a feature, report a bug, or participate in the general\ndiscussion, head over to `StoryBoard`_.\n\nLicense\n-------\n\nSee LICENSE file. Code was originally forked from Datadog\u2019s\ndogstatsd-python, hence the dual license.\n\n.. _StoryBoard: https://storyboard.openstack.org/#!/project/872\n\n\n\n",
"bugtrack_url": null,
"license": "Apache-2",
"summary": "Monasca statsd Python client",
"version": "2.7.0",
"project_urls": {
"Homepage": "https://opendev.org/openstack/monasca-statsd"
},
"split_keywords": [
"openstack",
"monitoring",
"statsd"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "32680c6669a6e174b7f1841dd5731f0dbf247b2d8c0d2b617f9c3b9a9c099b36",
"md5": "ee884b207c3de12c47962b105d7ee6f2",
"sha256": "0f956fd46bc6a046415548cda5b747726dc36782100bc8d677383bf14cd4a054"
},
"downloads": -1,
"filename": "monasca_statsd-2.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ee884b207c3de12c47962b105d7ee6f2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 20687,
"upload_time": "2023-09-07T10:03:07",
"upload_time_iso_8601": "2023-09-07T10:03:07.913069Z",
"url": "https://files.pythonhosted.org/packages/32/68/0c6669a6e174b7f1841dd5731f0dbf247b2d8c0d2b617f9c3b9a9c099b36/monasca_statsd-2.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "365d1d4e4cae5f4440b54e94729924eb1e72bff2028b3f9b81ff324253b18e22",
"md5": "3fd0356ce8032e0559a66762ca77ee80",
"sha256": "459390749466e13646985bb09b7046315a5f9dacc641f57b6928cee4f71b40db"
},
"downloads": -1,
"filename": "monasca-statsd-2.7.0.tar.gz",
"has_sig": false,
"md5_digest": "3fd0356ce8032e0559a66762ca77ee80",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 22269,
"upload_time": "2023-09-07T10:03:09",
"upload_time_iso_8601": "2023-09-07T10:03:09.640690Z",
"url": "https://files.pythonhosted.org/packages/36/5d/1d4e4cae5f4440b54e94729924eb1e72bff2028b3f9b81ff324253b18e22/monasca-statsd-2.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-07 10:03:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "monasca-statsd"
}