Skip to content

Commit

Permalink
Fix: leading dot when prefix empty
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnbutts committed Sep 22, 2016
1 parent 17a41a7 commit 98419a4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/diamond/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
The Collector class is a base class for all metric collectors.
Netuitive Change History
2016/07/11 DVG - Changed the publish_counter() function such that it actually does publish the
2016/07/11 DVG - Changed the publish_counter() function such that it actually does publish the
value as a COUNTER rather than a RATE. See comments inline for more detail.
"""
Expand Down Expand Up @@ -356,10 +356,13 @@ def get_metric_path(self, name, instance=None):
if suffix:
prefix = '.'.join((prefix, suffix))

if path == '.':
return '.'.join([prefix, name])
else:
return '.'.join([prefix, path, name])
path_r = [name]
if path and path != '.':
path_r.insert(0, path)
if prefix and prefix != '':
path_r.insert(0, prefix)

return '.'.join(path_r)

def get_hostname(self):
return get_hostname(self.config)
Expand Down Expand Up @@ -418,14 +421,14 @@ def publish_gauge(self, name, value, precision=0, instance=None):
def publish_counter(self, name, value, precision=0, max_value=0,
time_delta=True, interval=None, allow_negative=False,
instance=None):

###
#
# 2016/07/11 DVG - The original version of this code was calling
# self.derivative(), which first computes the differential (the
# difference between the current value and the previous value),
# and then divides by the interval. The end result was that the
# value published was a RATE and not actually a COUNTER, despite
# and then divides by the interval. The end result was that the
# value published was a RATE and not actually a COUNTER, despite
# the type being set to COUNTER.
#
###
Expand All @@ -435,7 +438,7 @@ def publish_counter(self, name, value, precision=0, max_value=0,
# time_delta=time_delta, interval=interval,
# allow_negative=allow_negative,
# instance=instance)
return self.publish(name, value,
return self.publish(name, value,
precision=precision, metric_type='COUNTER',
instance=instance)

Expand Down

0 comments on commit 98419a4

Please sign in to comment.