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)
|
||||
try:
|
||||
host, port = cfg.statsd_host
|
||||
self.prefix = cfg.statsd_prefix
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.sock.connect((host, int(port)))
|
||||
except Exception:
|
||||
@ -98,27 +99,27 @@ class Statsd(Logger):
|
||||
def gauge(self, name, value):
|
||||
try:
|
||||
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:
|
||||
pass
|
||||
|
||||
def increment(self, name, value, sampling_rate=1.0):
|
||||
try:
|
||||
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:
|
||||
pass
|
||||
|
||||
def decrement(self, name, value, sampling_rate=1.0):
|
||||
try:
|
||||
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:
|
||||
pass
|
||||
|
||||
def histogram(self, name, value):
|
||||
try:
|
||||
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:
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user