PKΊ@+O==$python-statsd-v1.4/statsd.timer.html statsd.timer — Python Statsd 1.0 documentation

statsd.timer

class statsd.timer.Timer(name, connection=None)

Statsd Timer Object

Additional documentation is available at the parent class Client

>>> timer = Timer('application_name')
>>> timer.start()
>>>  # do something
>>> timer.stop('executed_action')
decorate(function_or_name)

Decorate a function to time the execution

The method can be called with or without a name. If no name is given the function defaults to the name of the function.

Parameters:function_or_name – The name to post to or the function to wrap
>>> from statsd import Timer
>>> timer = Timer('application_name')
>>>
>>> @timer.decorate
... def some_function():
...     # resulting timer name: application_name.some_function
...     pass
>>>
>>> @timer.decorate('my_timer')
... def some_function():
...     # resulting timer name: application_name.my_timer
...     pass
intermediate(subname)

Send the time that has passed since our last measurement

Parameters:subname – The subname to report the data to (appended to the client name)
send(subname, delta)

Send the data to statsd via self.connection

Parameters:
  • subname – The subname to report the data to (appended to the client name)
  • delta – The time delta (time.time() - time.time()) to report
start()

Start the timer and store the start time, this can only be executed once per instance

stop(subname='total')

Stop the timer and send the total since start() was run

Parameters:subname – The subname to report the data to (appended to the client name)

Project Versions

Previous topic

statsd.client

Next topic

statsd.counter

This Page

PKΊ@)%%#python-statsd-v1.4/py-modindex.html Python Module Index — Python Statsd 1.0 documentation

Python Module Index

s
 
s
statsd
    statsd.client
    statsd.connection
    statsd.counter
    statsd.timer

Project Versions

PK͊@o<,))python-statsd-v1.4/index.html Python Statsd Client — Python Statsd 1.0 documentation

Project Versions

Table Of Contents

Next topic

Introduction

This Page

PKΊ@jnDDpython-statsd-v1.4/usage.html Introduction — Python Statsd 1.0 documentation

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

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')

Project Versions

Table Of Contents

Previous topic

Python Statsd Client

Next topic

Statsd Module Reference

This Page

PKΊ@ Ԗ !python-statsd-v1.4/searchindex.jsSearch.setIndex({objects:{statsd:{connection:[4,0,1,""],counter:[3,0,1,""],timer:[5,0,1,""],client:[1,0,1,""]},"statsd.connection.Connection":{send:[4,1,1,""]},"statsd.counter.Counter":{decrement:[3,1,1,""],increment:[3,1,1,""]},"statsd.counter":{Counter:[3,2,1,""]},"statsd.connection":{Connection:[4,2,1,""]},"statsd.client":{Client:[1,2,1,""]},"statsd.timer":{Timer:[5,2,1,""]},"statsd.timer.Timer":{start:[5,1,1,""],intermediate:[5,1,1,""],stop:[5,1,1,""],decorate:[5,1,1,""],send:[5,1,1,""]},"statsd.client.Client":{connection:[1,3,1,""],get_client:[1,1,1,""],name:[1,3,1,""]}},terms:{code:6,just:6,over:4,global:1,remov:3,front:6,prefix:1,per:[1,5],paramet:[3,1,5,4],onli:5,execut:[6,5],graph:6,intermedi:5,"__class__":6,send:[5,4],should:4,blog:6,add:3,wikidot:6,intermediate_valu:6,modul:[0,2],sent:[1,4],real:6,statsd:[0,1,2,3,4,5,6],get:[6,1],python:[6,0],stop:[6,5],none:[3,1,5,4],know:4,"import":[6,5],report:[3,5],introduct:[6,0],application_nam:[3,5],measur:[6,5],like:6,specif:6,anyth:6,some_funct:5,server:6,separ:1,collect:6,either:3,quick:6,page:0,mean:4,interv:6,see:1,sampl:[6,4],connect:[0,1,2,3,4,5,6],pass:5,our:5,port:[6,4],append:[3,5],index:0,what:4,sub:1,get_client:[6,1],someth:[6,5],subclass:1,content:[0,2],delet:3,statd:3,between:4,"new":1,method:[3,5],localhost:4,refer:[0,2],run:[6,5],proxi:6,parent:[3,5],advanc:[6,0],codeascraft:6,someclass:6,usag:[6,0],statsd_client:6,here:6,host:4,base:1,"__name__":6,post:[6,5],do_someth:6,sinc:5,valu:3,addit:[3,5],search:0,last:5,task_id:1,statsd_connect:6,commun:4,timer:[6,0,1,5,2],instanc:5,nosetest:6,implement:3,com:6,first:6,via:5,simpli:[6,3],onc:5,app:1,number:4,wrap:5,instal:[6,0],decrement:3,total:[6,5],open:6,given:[1,5],from:[3,1,5],creat:[6,1],wai:1,spam:1,sometim:6,messag:4,name:[6,3,1,5],avail:[3,5],start:[6,5],call:5,basic:[6,0],store:5,"function":[1,5],udp:4,my_tim:5,namespac:1,etsi:6,delta:[3,5],than:1,account:4,"default":[5,4],setup:6,rate:[6,4],executed_act:5,"while":4,graphit:6,can:[3,1,5],def:[6,5],result:[1,5],increment:3,function_or_nam:5,applic:6,argument:1,indic:[0,4],want:6,tabl:0,"__init__":6,probabl:4,alwai:4,decor:5,end:6,myapplic:6,self:[6,5],also:4,subclient:1,client:[0,1,2,3,5,6],subnam:[3,5],take:4,which:4,test:6,you:[6,1],document:[3,5],stat:6,http:6,multipli:4,object:[6,3,1,5],class_:[6,1],data:[3,5,4],"class":[6,3,1,5,4],github:6,els:6,"try":6,counter:[6,0,3,1,2],sample_r:[6,4],counter_nam:3,without:5,thi:[6,1,5],time:5,everyth:[6,1],egg:1},objtypes:{"0":"py:module","1":"py:method","2":"py:class","3":"py:attribute"},titles:["Python Statsd Client","statsd.client","Statsd Module Reference","statsd.counter","statsd.connection","statsd.timer","Introduction"],objnames:{"0":["py","module","Python module"],"1":["py","method","Python method"],"2":["py","class","Python class"],"3":["py","attribute","Python attribute"]},filenames:["index","statsd.client","statsd","statsd.counter","statsd.connection","statsd.timer","usage"]})PKΊ@bpython-statsd-v1.4/objects.inv# Sphinx inventory version 2 # Project: Python Statsd # Version: 1.0 # The remainder of this file is compressed using zlib. xڥ=O0 `mD[;1 !rF)q%kzT_c[S"'0Swh{7/W!o'EJ t7W!CCGlXJY41Rҡ(y@nunysXեzYDFĸ/xcQb1]b &`ϔݣmHHadp ĠO= Lm Ta+>;0g|"sןk'R&'x`/!Â+!PKΊ@@)7!!python-statsd-v1.4/search.html Search — Python Statsd 1.0 documentation

Search

Please activate JavaScript to enable the search functionality.

From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list.

Project Versions

PKΊ@hDx/x/ python-statsd-v1.4/genindex.html Index — Python Statsd 1.0 documentation

Project Versions

PKΊ@|;t9t9&python-statsd-v1.4/statsd.counter.html statsd.counter — Python Statsd 1.0 documentation

statsd.counter

class statsd.counter.Counter(name, connection=None)

Class to implement a statd counter

Additional documentation is available at the parent class Client

The values can be incremented/decremented by using either the increment() and decrement() methods or by simply adding/deleting from the object.

>>> counter = Counter('application_name')
>>> counter += 10
>>> counter = Counter('application_name')
>>> counter -= 10
decrement(subname=None, delta=1)

Decrement the counter with delta

Parameters:
  • subname – The subname to report the data to (appended to the client name)
  • delta – The delta to remove from the counter
>>> counter = Counter('application_name')
>>> counter.decrement('counter_name', 10)
>>> counter.decrement(delta=10)
>>> counter.decrement('counter_name')
increment(subname=None, delta=1)

Increment the counter with delta

Parameters:
  • subname – The subname to report the data to (appended to the client name)
  • delta – The delta to add to the counter
>>> counter = Counter('application_name')
>>> counter.increment('counter_name', 10)
>>> counter.increment(delta=10)
>>> counter.increment('counter_name')

Project Versions

Previous topic

statsd.timer

This Page

PKΊ@hpython-statsd-v1.4/.buildinfo# Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. config: f8d83b85dd168ab5353488e4f63505fc tags: fbb0d17656682115ca4d033fb2f83ba1 PK͊@qմ9'9'python-statsd-v1.4/statsd.html Statsd Module Reference — Python Statsd 1.0 documentation

Statsd Module Reference

Contents:

Project Versions

Previous topic

Introduction

Next topic

statsd.connection

This Page

PKΊ@44%python-statsd-v1.4/statsd.client.html statsd.client — Python Statsd 1.0 documentation

statsd.client

class statsd.client.Client(name, connection=None)

Statsd Client Object

Parameters:
connection = None

The Connection to use, creates a new connection if no connection is given

get_client(name=None, class_=None)

Get a (sub-)client with a separate namespace This way you can create a global/app based client with subclients per class/function

Parameters:
  • name – The name to use, if the name for this client was spam and the name argument is eggs than the resulting name will be spam.eggs
  • class – The Client subclass to use (e.g. Timer or Counter)
name = None

The name of the client, everything sent from this client will be prefixed by name

Project Versions

Previous topic

statsd.connection

Next topic

statsd.timer

This Page

PKΊ@ɂS,,)python-statsd-v1.4/statsd.connection.html statsd.connection — Python Statsd 1.0 documentation

statsd.connection

class statsd.connection.Connection(host=None, port=None, sample_rate=None)

Statsd Connection

Parameters:
  • host – The statsd host to connect to, defaults to localhost
  • port – The statsd port to connect to, defaults to 8125
  • sample_rate – The sample rate, defaults to 1 (meaning always)
send(data, sample_rate=None)

Send the data over UDP while taking the sample_rate in account

The sample rate should be a number between 0 and 1 which indicates the probability that a message will be sent. The sample_rate is also communicated to statsd so it knows what multiplier to use.

Project Versions

Previous topic

Statsd Module Reference

Next topic

statsd.client

This Page

PKΊ@:>>>)python-statsd-v1.4/_static/searchtools.js/* * searchtools.js_t * ~~~~~~~~~~~~~~~~ * * Sphinx JavaScript utilties for the full-text search. * * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ /** * helper function to return a node containing the * search summary for a given text. keywords is a list * of stemmed words, hlwords is the list of normal, unstemmed * words. the first one is used to find the occurance, the * latter for highlighting it. */ jQuery.makeSearchSummary = function(text, keywords, hlwords) { var textLower = text.toLowerCase(); var start = 0; $.each(keywords, function() { var i = textLower.indexOf(this.toLowerCase()); if (i > -1) start = i; }); start = Math.max(start - 120, 0); var excerpt = ((start > 0) ? '...' : '') + $.trim(text.substr(start, 240)) + ((start + 240 - text.length) ? '...' : ''); var rv = $('
').text(excerpt); $.each(hlwords, function() { rv = rv.highlightText(this, 'highlighted'); }); return rv; } /** * Porter Stemmer */ var Stemmer = function() { var step2list = { ational: 'ate', tional: 'tion', enci: 'ence', anci: 'ance', izer: 'ize', bli: 'ble', alli: 'al', entli: 'ent', eli: 'e', ousli: 'ous', ization: 'ize', ation: 'ate', ator: 'ate', alism: 'al', iveness: 'ive', fulness: 'ful', ousness: 'ous', aliti: 'al', iviti: 'ive', biliti: 'ble', logi: 'log' }; var step3list = { icate: 'ic', ative: '', alize: 'al', iciti: 'ic', ical: 'ic', ful: '', ness: '' }; var c = "[^aeiou]"; // consonant var v = "[aeiouy]"; // vowel var C = c + "[^aeiouy]*"; // consonant sequence var V = v + "[aeiou]*"; // vowel sequence var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 var s_v = "^(" + C + ")?" + v; // vowel in stem this.stemWord = function (w) { var stem; var suffix; var firstch; var origword = w; if (w.length < 3) return w; var re; var re2; var re3; var re4; firstch = w.substr(0,1); if (firstch == "y") w = firstch.toUpperCase() + w.substr(1); // Step 1a re = /^(.+?)(ss|i)es$/; re2 = /^(.+?)([^s])s$/; if (re.test(w)) w = w.replace(re,"$1$2"); else if (re2.test(w)) w = w.replace(re2,"$1$2"); // Step 1b re = /^(.+?)eed$/; re2 = /^(.+?)(ed|ing)$/; if (re.test(w)) { var fp = re.exec(w); re = new RegExp(mgr0); if (re.test(fp[1])) { re = /.$/; w = w.replace(re,""); } } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1]; re2 = new RegExp(s_v); if (re2.test(stem)) { w = stem; re2 = /(at|bl|iz)$/; re3 = new RegExp("([^aeiouylsz])\\1$"); re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re2.test(w)) w = w + "e"; else if (re3.test(w)) { re = /.$/; w = w.replace(re,""); } else if (re4.test(w)) w = w + "e"; } } // Step 1c re = /^(.+?)y$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(s_v); if (re.test(stem)) w = stem + "i"; } // Step 2 re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step2list[suffix]; } // Step 3 re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; suffix = fp[2]; re = new RegExp(mgr0); if (re.test(stem)) w = stem + step3list[suffix]; } // Step 4 re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; re2 = /^(.+?)(s|t)(ion)$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); if (re.test(stem)) w = stem; } else if (re2.test(w)) { var fp = re2.exec(w); stem = fp[1] + fp[2]; re2 = new RegExp(mgr1); if (re2.test(stem)) w = stem; } // Step 5 re = /^(.+?)e$/; if (re.test(w)) { var fp = re.exec(w); stem = fp[1]; re = new RegExp(mgr1); re2 = new RegExp(meq1); re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) w = stem; } re = /ll$/; re2 = new RegExp(mgr1); if (re.test(w) && re2.test(w)) { re = /.$/; w = w.replace(re,""); } // and turn initial Y back to y if (firstch == "y") w = firstch.toLowerCase() + w.substr(1); return w; } } /** * Search Module */ var Search = { _index : null, _queued_query : null, _pulse_status : -1, init : function() { var params = $.getQueryParameters(); if (params.q) { var query = params.q[0]; $('input[name="q"]')[0].value = query; this.performSearch(query); } }, loadIndex : function(url) { $.ajax({type: "GET", url: url, data: null, success: null, dataType: "script", cache: true}); }, setIndex : function(index) { var q; this._index = index; if ((q = this._queued_query) !== null) { this._queued_query = null; Search.query(q); } }, hasIndex : function() { return this._index !== null; }, deferQuery : function(query) { this._queued_query = query; }, stopPulse : function() { this._pulse_status = 0; }, startPulse : function() { if (this._pulse_status >= 0) return; function pulse() { Search._pulse_status = (Search._pulse_status + 1) % 4; var dotString = ''; for (var i = 0; i < Search._pulse_status; i++) dotString += '.'; Search.dots.text(dotString); if (Search._pulse_status > -1) window.setTimeout(pulse, 500); }; pulse(); }, /** * perform a search for something */ performSearch : function(query) { // create the required interface elements this.out = $('#search-results'); this.title = $('

' + _('Searching') + '

').appendTo(this.out); this.dots = $('').appendTo(this.title); this.status = $('

').appendTo(this.out); this.output = $('