Skip to main content

statsd is a client for Etsy's node-js statsd server. A proxy for the Graphite stats collection and graphing server.

Project description

Introduction

statsd is a client for Etsy’s statsd server, a front end/proxy for the Graphite stats collection and graphing server.

Install

To install simply execute python setup.py install. If you want to run the tests first, run python setup.py nosetests

Usage

To get started real quick, just try something like this:

Basic Usage

Timers

>>> import statsd
>>>
>>> timer = statsd.Timer('MyApplication')
>>>
>>> timer.start()
>>> # do something here
>>> timer.stop('SomeTimer')

Counters

>>> import statsd
>>>
>>> counter = statsd.Counter('MyApplication')
>>> # do something here
>>> counter += 1

Gauge

>>> import statsd
>>>
>>> gauge = statsd.Counter('MyApplication')
>>> # do something here
>>> gauge.send('SomeName', value)

Advanced Usage

>>> import statsd
>>>
>>> # Open a connection to `server` on port `1234` with a `50%` sample rate
>>> statsd_connection = statsd.Connection(
...     host='server',
...     port=1234,
...     sample_rate=0.5,
... )
>>>
>>> # Create a client for this application
>>> statsd_client = statsd.Client(__name__, statsd_connection)
>>>
>>> class SomeClass(object):
...     def __init__(self):
...         # Create a client specific for this class
...         self.statsd_client = statsd_client.get_client(
...             self.__class__.__name__)
...
...     def do_something(self):
...         # Create a `timer` client
...         timer = self.statsd_client.get_client(class_=statsd.Timer)
...
...         # start the measurement
...         timer.start()
...
...         # do something
...         timer.interval('intermediate_value')
...
...         # do something else
...         timer.stop('total')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-statsd-1.4.3.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file python-statsd-1.4.3.tar.gz.

File metadata

File hashes

Hashes for python-statsd-1.4.3.tar.gz
Algorithm Hash digest
SHA256 dcf15256cb017e72efb7fe5124064035a5bb43d0860f38f2d9aa3c97fa684b6a
MD5 dfadf9da461c4dc99c87f7ea6acb1397
BLAKE2b-256 35022c6cf25d2f77b3ec6ede5ecfe4877d1c3508ff3a352f3bcd90e26c55c045

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page