Skip to content

Commit

Permalink
check whether or not _start_flush_thread is being called for bufferin…
Browse files Browse the repository at this point in the history
…g or aggregation before returning
  • Loading branch information
andrewqian2001datadog committed Jul 22, 2024
1 parent b7b498a commit 3da584c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,21 @@ def enable_telemetry(self):

# Note: Invocations of this method should be thread-safe
def _start_flush_thread(self, flush_interval, min_flush_interval, flush_function, flush_thread_container, flush_thread_stop):
if self._disable_buffering:
if self._disable_buffering and flush_function == self.flush_buffered_metrics:
log.debug("Statsd periodic buffer flush is disabled")
return
if self._disable_aggregating and flush_function == self.flush_aggregated_metrics:
log.debug("Statsd periodic aggregating flush is disabled")
return

flush_type = ''
if self._disable_buffering:
flush_type = 'aggregation'
else:
flush_type = 'buffering'

if flush_interval <= min_flush_interval:
log.debug("flush_interval for either buffering or aggregation is less then the min_flush_interval")
log.debug("the set flush interval for %s is less then the minimum", flush_type)
return

if self._forking:
Expand All @@ -566,7 +576,8 @@ def _flush_thread_loop(self, flush_interval):
new_thread.start()
flush_thread_container[0] = new_thread
log.debug(
"Statsd flush thread registered with period of %s",
"Statsd %s flush thread registered with period of %s",
flush_type,
flush_interval,
)

Expand Down

0 comments on commit 3da584c

Please sign in to comment.