Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dogstatsd] Parse distribution metrics and ignore them #3458

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ class Aggregator(object):
"""
# Types of metrics that allow strings
ALLOW_STRINGS = ['s', ]
# Types that are not implemented and ignored
IGNORE_TYPES = ['d', ]

def __init__(self, hostname, interval=1.0, expiry_seconds=300,
formatter=None, recent_point_threshold=None,
Expand Down Expand Up @@ -472,6 +474,8 @@ def parse_metric_packet(self, packet):

if metric_type in self.ALLOW_STRINGS:
value = raw_value
elif metric_type in self.IGNORE_TYPES:
continue
else:
# Try to cast as an int first to avoid precision issues, then as a
# float.
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ def test_string_sets(self):
# Assert there are no more sets
assert not stats.flush()

def test_ignore_distribution(self):
stats = MetricsAggregator('myhost')
stats.submit_packets('my.dist:5.0|d')
stats.submit_packets('my.gauge:1|g')

# Assert that it's treated normally, and that the distribution is ignored
metrics = stats.flush()
nt.assert_equal(len(metrics), 1)
m = metrics[0]
nt.assert_equal(m['metric'], 'my.gauge')
nt.assert_equal(m['points'][0][1], 1)

@attr(requires='core_integration')
def test_rate(self):
stats = MetricsAggregator('myhost')
Expand Down