mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Prefix statsd metric strings with the prefix
This commit is contained in:
parent
34b56d5973
commit
eb3bf34066
@ -27,6 +27,7 @@ class Statsd(Logger):
|
|||||||
Logger.__init__(self, cfg)
|
Logger.__init__(self, cfg)
|
||||||
try:
|
try:
|
||||||
host, port = cfg.statsd_host
|
host, port = cfg.statsd_host
|
||||||
|
self.prefix = cfg.statsd_prefix
|
||||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
self.sock.connect((host, int(port)))
|
self.sock.connect((host, int(port)))
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -98,27 +99,27 @@ class Statsd(Logger):
|
|||||||
def gauge(self, name, value):
|
def gauge(self, name, value):
|
||||||
try:
|
try:
|
||||||
if self.sock:
|
if self.sock:
|
||||||
self.sock.send("{0}:{1}|g".format(name, value))
|
self.sock.send("{0}{1}:{2}|g".format(self.prefix, name, value))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def increment(self, name, value, sampling_rate=1.0):
|
def increment(self, name, value, sampling_rate=1.0):
|
||||||
try:
|
try:
|
||||||
if self.sock:
|
if self.sock:
|
||||||
self.sock.send("{0}:{1}|c|@{2}".format(name, value, sampling_rate))
|
self.sock.send("{0}{1}:{2}|c|@{3}".format(self.prefix, name, value, sampling_rate))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def decrement(self, name, value, sampling_rate=1.0):
|
def decrement(self, name, value, sampling_rate=1.0):
|
||||||
try:
|
try:
|
||||||
if self.sock:
|
if self.sock:
|
||||||
self.sock.send("{0}:-{1}|c|@{2}".format(name, value, sampling_rate))
|
self.sock.send("{0){1}:-{2}|c|@{3}".format(self.prefix, name, value, sampling_rate))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def histogram(self, name, value):
|
def histogram(self, name, value):
|
||||||
try:
|
try:
|
||||||
if self.sock:
|
if self.sock:
|
||||||
self.sock.send("{0}:{1}|ms".format(name, value))
|
self.sock.send("{0}{1}:{2}|ms".format(self.prefix, name, value))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user