Skip to content

Commit

Permalink
[aggregator] if sample rate is bad, fix it but still parse tags. (#3073)
Browse files Browse the repository at this point in the history
[aggregator] refactor, for readability
  • Loading branch information
truthbk authored Dec 13, 2016
1 parent 0369d53 commit 6df4554
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,14 @@ def parse_metric_packet(self, packet):
# Parse the sample rate
if m[0] == '@':
sample_rate = float(m[1:])
assert 0 <= sample_rate <= 1
# in case it's in a bad state
sample_rate = 1 if sample_rate < 0 or sample_rate > 1 else sample_rate
elif m[0] == '#':
tags = tuple(sorted(m[1:].split(',')))
except (IndexError, AssertionError):
except IndexError:
log.warning(u'Incorrect metric metadata: metric_name:%s, metadata:%s',
name, u' '.join(value_and_metadata[2:]))
sample_rate = 1 # In case it's in a bad state

parsed_packets.append((name, value, metric_type, tags, sample_rate))

return parsed_packets
Expand Down

0 comments on commit 6df4554

Please sign in to comment.