Skip to content

Commit b46b539

Browse files
update base.py to not use new feature unless max_samples_per_context is set
1 parent b2f714b commit b46b539

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

datadog/dogstatsd/base.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -982,10 +982,10 @@ def histogram(
982982
>>> statsd.histogram("uploaded.file.size", 1445)
983983
>>> statsd.histogram("album.photo.count", 26, tags=["gender:female"])
984984
"""
985-
if self._disable_aggregation:
986-
self._report(metric, "h", value, tags, sample_rate)
987-
else:
985+
if not self._disable_aggregation and self.aggregator.max_samples_per_context != 0:
988986
self.aggregator.histogram(metric, value, tags, sample_rate)
987+
else:
988+
self._report(metric, "h", value, tags, sample_rate)
989989

990990
def distribution(
991991
self,
@@ -1000,10 +1000,10 @@ def distribution(
10001000
>>> statsd.distribution("uploaded.file.size", 1445)
10011001
>>> statsd.distribution("album.photo.count", 26, tags=["gender:female"])
10021002
"""
1003-
if self._disable_aggregation:
1004-
self._report(metric, "d", value, tags, sample_rate)
1005-
else:
1003+
if not self._disable_aggregation and self.aggregator.max_samples_per_context != 0:
10061004
self.aggregator.distribution(metric, value, tags, sample_rate)
1005+
else:
1006+
self._report(metric, "d", value, tags, sample_rate)
10071007

10081008
def timing(
10091009
self,
@@ -1017,11 +1017,10 @@ def timing(
10171017
10181018
>>> statsd.timing("query.response.time", 1234)
10191019
"""
1020-
1021-
if self._disable_aggregation:
1022-
self._report(metric, "ms", value, tags, sample_rate)
1023-
else:
1020+
if not self._disable_aggregation and self.aggregator.max_samples_per_context != 0:
10241021
self.aggregator.timing(metric, value, tags, sample_rate)
1022+
else:
1023+
self._report(metric, "ms", value, tags, sample_rate)
10251024

10261025
def timed(self, metric=None, tags=None, sample_rate=None, use_ms=None):
10271026
"""

0 commit comments

Comments
 (0)