Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewqian2001datadog committed Aug 22, 2024
1 parent 22c6f48 commit 9749ea4
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(
port=DEFAULT_PORT, # type: int
max_buffer_size=None, # type: None
flush_interval=DEFAULT_FLUSH_INTERVAL, # type: float
disable_aggregating=True, # type: bool
disable_aggregation=True, # type: bool
disable_buffering=True, # type: bool
namespace=None, # type: Optional[Text]
constant_tags=None, # type: Optional[List[str]]
Expand Down Expand Up @@ -236,8 +236,8 @@ def __init__(
it overrides the default value.
:type flush_interval: float
:disable_aggregating: If true, metrics (Count, Gauge, Set) are no longered aggregated by the client
:type disable_aggregating: bool
:disable_aggregation: If true, metrics (Count, Gauge, Set) are no longered aggregated by the client
:type disable_aggregation: bool
:disable_buffering: If set, metrics are no longered buffered by the client and
all data is sent synchronously to the server
Expand Down Expand Up @@ -445,7 +445,7 @@ def __init__(
self._config_lock = RLock()

self._disable_buffering = disable_buffering
self._disable_aggregating = disable_aggregating
self._disable_aggregation = disable_aggregation

self._flush_interval = flush_interval
self._flush_thread = None
Expand All @@ -459,7 +459,7 @@ def __init__(
else:
self._send = self._send_to_server

if not self._disable_aggregating or not self._disable_buffering:
if not self._disable_aggregation or not self._disable_buffering:
self._start_flush_thread()
else:
log.debug("Statsd buffering and aggregation is disabled")
Expand Down Expand Up @@ -540,7 +540,7 @@ def enable_telemetry(self):

# Note: Invocations of this method should be thread-safe
def _start_flush_thread(self):
if self._disable_aggregating and self.disable_buffering:
if self._disable_aggregation and self.disable_buffering:
log.debug("Statsd periodic buffer and aggregation flush is disabled")
return

Expand All @@ -559,7 +559,7 @@ def _start_flush_thread(self):
def _flush_thread_loop(self, flush_interval):
while not self._flush_thread_stop.is_set():
time.sleep(flush_interval)
if not self._disable_aggregating:
if not self._disable_aggregation:
self.flush_aggregated_metrics()
if not self._disable_buffering:
self.flush_buffered_metrics()
Expand All @@ -580,7 +580,7 @@ def _stop_flush_thread(self):
if not self._flush_thread:
return
try:
if not self._disable_aggregating:
if not self._disable_aggregation:
self.flush_aggregated_metrics()
if not self.disable_buffering:
self.flush_buffered_metrics()
Expand Down Expand Up @@ -622,7 +622,7 @@ def disable_buffering(self, is_disabled):
# otherwise start up the flushing thread and enable the buffering.
if is_disabled:
self._send = self._send_to_server
if self._disable_aggregating and self.disable_buffering:
if self._disable_aggregation and self.disable_buffering:
self._stop_flush_thread()
log.debug("Statsd buffering is disabled")
else:
Expand All @@ -632,22 +632,22 @@ def disable_buffering(self, is_disabled):
def disable_aggregation(self):
with self._config_lock:
# If the toggle didn't change anything, this method is a noop
if self._disable_aggregating:
if self._disable_aggregation:
return

self._disable_aggregating = True
self._disable_aggregation = True

# If aggregation and buffering has been disabled, flush and kill the background thread
# otherwise start up the flushing thread and enable aggregation.
if self._disable_aggregating and self.disable_buffering:
if self._disable_aggregation and self.disable_buffering:
self._stop_flush_thread()
log.debug("Statsd aggregation is disabled")

def enable_aggregation(self, flush_interval=DEFAULT_FLUSH_INTERVAL):
with self._config_lock:
if not self._disable_aggregating:
if not self._disable_aggregation:
return
self._disable_aggregating = False
self._disable_aggregation = False
self._flush_interval = flush_interval
if self._disable_buffering:
self._send = self._send_to_server
Expand Down Expand Up @@ -837,7 +837,7 @@ def gauge(
>>> statsd.gauge("users.online", 123)
>>> statsd.gauge("active.connections", 1001, tags=["protocol:http"])
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "g", value, tags, sample_rate)
else:
self.aggregator.gauge(metric, value, tags, sample_rate)
Expand All @@ -860,7 +860,7 @@ def gauge_with_timestamp(
>>> statsd.gauge("users.online", 123, 1713804588)
>>> statsd.gauge("active.connections", 1001, 1713804588, tags=["protocol:http"])
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "g", value, tags, sample_rate, timestamp)
else:
self.aggregator.gauge(metric, value, tags, sample_rate, timestamp)
Expand All @@ -878,7 +878,7 @@ def count(
>>> statsd.count("page.views", 123)
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "c", value, tags, sample_rate)
else:
self.aggregator.count(metric, value, tags, sample_rate)
Expand All @@ -900,7 +900,7 @@ def count_with_timestamp(
>>> statsd.count("files.transferred", 124, timestamp=1713804588)
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "c", value, tags, sample_rate, timestamp)
else:
self.aggregator.count(metric, value, tags, sample_rate, timestamp)
Expand All @@ -919,7 +919,7 @@ def increment(
>>> statsd.increment("page.views")
>>> statsd.increment("files.transferred", 124)
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "c", value, tags, sample_rate)
else:
self.aggregator.count(metric, value, tags, sample_rate)
Expand All @@ -939,7 +939,7 @@ def decrement(
>>> statsd.decrement("active.connections", 2)
"""
metric_value = -value if value else value
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "c", metric_value, tags, sample_rate)
else:
self.aggregator.count(metric, metric_value, tags, sample_rate)
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def set(self, metric, value, tags=None, sample_rate=None):
>>> statsd.set("visitors.uniques", 999)
"""
if self._disable_aggregating:
if self._disable_aggregation:
self._report(metric, "s", value, tags, sample_rate)
else:
self.aggregator.set(metric, value, tags, sample_rate)
Expand Down Expand Up @@ -1539,7 +1539,7 @@ def stop(self):

self.disable_background_sender()
self._disable_buffering = True
self._disable_aggregating = True
self._disable_aggregation = True
self.flush_aggregated_metrics()
self.flush_buffered_metrics()
self.close_socket()
Expand Down

0 comments on commit 9749ea4

Please sign in to comment.