statsd.gauge

class statsd.gauge.Gauge(name, connection=None)[source]

Class to implement a statsd gauge

decrement(subname=None, delta=1)[source]

Decrement the gauge with delta

Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • delta (int) – The delta to remove from the gauge
>>> gauge = Gauge('application_name')
>>> gauge.decrement('gauge_name', 10)
True
>>> gauge.decrement(delta=10)
True
>>> gauge.decrement('gauge_name')
True
increment(subname=None, delta=1)[source]

Increment the gauge with delta

Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • delta (int) – The delta to add to the gauge
>>> gauge = Gauge('application_name')
>>> gauge.increment('gauge_name', 10)
True
>>> gauge.increment(delta=10)
True
>>> gauge.increment('gauge_name')
True
send(subname, value)[source]

Send the data to statsd via self.connection

Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • value – The gauge value to send
set(subname, value)[source]
Set the data ignoring the sign, ie set(“test”, -1) will
set “test” exactly to -1 (not decrement it by 1)

See https://github.com/etsy/statsd/blob/master/docs/metric_types.md “Adding a sign to the gauge value will change the value, rather

than setting it.
gaugor:-10|g gaugor:+4|g
So if gaugor was 333, those commands would set it to 333 - 10 + 4,
or 327.

Note: This implies you can’t explicitly set a gauge to a negative number

without first setting it to zero.”
Parameters:
  • subname (str) – The subname to report the data to (appended to the client name)
  • value – The new gauge value