8000 Support for namespace in graphite bridge #49 · rmohr/client_python@c5fff61 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5fff61

Browse files
author
Vikas Kumar
committed
Support for namespace in graphite bridge prometheus#49
1. Added an optional parameter `prefix` to `bridge.graphite.GraphiteBridge.push()`. 2. Initialize _RegularPush with `prefix`.
1 parent 9e2b366 commit c5fff61

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

prometheus_client/bridge/graphite.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def _sanitize(s):
1919

2020

2121
class _RegularPush(threading.Thread):
22-
def __init__(self, pusher, interval):
22+
def __init__(self, pusher, interval, prefix):
2323
super(_RegularPush, self).__init__()
2424
self._pusher = pusher
2525
self._interval = interval
26+
self._prefix = prefix
2627

2728
def run(self):
2829
wait_until = time.time()
@@ -37,7 +38,7 @@ def run(self):
3738
# time.sleep can return early.
3839
time.sleep(wait_until - now)
3940
try:
40-
self._pusher.push()
41+
self._pusher.push(prefix=self._prefix)
4142
except IOError:
4243
logging.exception("Push failed")
4344

@@ -73,7 +74,7 @@ def push(self, prefix=''):
7374
conn.sendall(''.join(output).encode('ascii'))
7475
conn.close()
7576

76-
def start(self, interval=60.0):
77-
t = _RegularPush(self, interval)
77+
def start(self, interval=60.0, prefix=''):
78+
t = _RegularPush(self, interval, prefix)
7879
t.daemon = True
7980
t.start()

0 commit comments

Comments
 (0)
0