Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion graphitesend/graphitesend.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class GraphiteClient(object):
:type dryrun: True or False
:param timeout_in_seconds: Number of seconds before a connection is timed out.
:param asynchronous: Send messages asynchronouly via gevent
:param clean_metric_name: Does GraphiteClient needs to clean metric's name
:type clean_metric_name: True or False
It will then send any metrics that you give it via
the .send() or .send_dict().

Expand Down Expand Up @@ -80,7 +82,8 @@ def __init__(self, prefix=None, graphite_server=None, graphite_port=2003,
timeout_in_seconds=2, debug=False, group=None,
system_name=None, suffix=None, lowercase_metric_names=False,
connect_on_create=True, fqdn_squash=False,
dryrun=False, asynchronous=False, autoreconnect=False):
dryrun=False, asynchronous=False, autoreconnect=False,
clean_metric_name=True):
"""
setup the connection to the graphite server and work out the
prefix.
Expand Down Expand Up @@ -116,6 +119,7 @@ def __init__(self, prefix=None, graphite_server=None, graphite_port=2003,
self.lowercase_metric_names = lowercase_metric_names
self.asynchronous = asynchronous
self._autoreconnect = autoreconnect
self._clean_metric_name = clean_metric_name

if prefix is None:
tmp_prefix = 'systems.'
Expand Down Expand Up @@ -208,6 +212,8 @@ def clean_metric_name(self, metric_name):
"""
Make sure the metric is free of control chars, spaces, tabs, etc.
"""
if not self._clean_metric_name:
return metric_name
metric_name = metric_name.replace('(', '_').replace(')', '')
metric_name = metric_name.replace(' ', '_').replace('-', '_')
metric_name = metric_name.replace('/', '_').replace('\\', '_')
Expand Down