SheepDogInc / python-statsd

Python Client for the Etsy NodeJS Statsd Server

Home Page:http://readthedocs.org/docs/python-statsd/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Settings

statsd will look for a local_settings file. with default settings for a connection. with support for django.conf.settings override.

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

Advanced Usage

>>> import statsd >>> >>> # Open a connection to server on port 1234 with a 50% sample rate >>> statsd_connection = statsd.Connection( ... name='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')

About

Python Client for the Etsy NodeJS Statsd Server

http://readthedocs.org/docs/python-statsd/en/latest/


Languages

Language:Python 85.5%Language:Shell 14.5%