Skip to content

Commit ee1249a

Browse files
chore: remove unnecessary extension_thread_stats
1 parent 1e564c9 commit ee1249a

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

datadog_lambda/dogstatsd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ def distribution(self, metric, value, tags=None, timestamp=None):
6262
6363
>>> statsd.distribution("uploaded.file.size", 1445)
6464
>>> statsd.distribution("album.photo.count", 26, tags=["gender:female"])
65-
>>> statsd.distribution("historic.file.count", 5, timestamp=int(datetime(2020, 2, 14, 12, 0, 0).timestamp()))
65+
>>> statsd.distribution(
66+
>>> "historic.file.count",
67+
>>> 5,
68+
>>> timestamp=int(datetime(2020, 2, 14, 12, 0, 0).timestamp()),
69+
>>> )
6670
"""
6771
self._report(metric, "d", value, tags, timestamp)
6872

datadog_lambda/metric.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
logger = logging.getLogger(__name__)
1717

1818
lambda_stats = None
19-
extension_thread_stats = None
2019

2120
flush_in_thread = os.environ.get("DD_FLUSH_IN_THREAD", "").lower() == "true"
2221

@@ -129,18 +128,6 @@ def write_metric_point_to_stdout(metric_name, value, timestamp=None, tags=None):
129128
def flush_stats(lambda_context=None):
130129
lambda_stats.flush()
131130

132-
if extension_thread_stats is not None:
133-
tags = None
134-
if lambda_context is not None:
135-
tags = get_enhanced_metrics_tags(lambda_context)
136-
split_arn = lambda_context.invoked_function_arn.split(":")
137-
if len(split_arn) > 7:
138-
# Get rid of the alias
139-
split_arn.pop()
140-
arn = ":".join(split_arn)
141-
tags.append("function_arn:" + arn)
142-
extension_thread_stats.flush(tags)
143-
144131

145132
def submit_enhanced_metric(metric_name, lambda_context):
146133
"""Submits the enhanced metric with the given name

tests/test_metric.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,16 @@ def test_lambda_metric_flush_to_log_with_extension(self):
4444

4545
@patch("datadog_lambda.metric.should_use_extension", True)
4646
def test_lambda_metric_timestamp_with_extension(self):
47-
patcher = patch("datadog_lambda.metric.extension_thread_stats")
48-
self.mock_metric_extension_thread_stats = patcher.start()
49-
self.addCleanup(patcher.stop)
50-
5147
delta = timedelta(minutes=1)
5248
timestamp = int((datetime.now() - delta).timestamp())
5349

5450
lambda_metric("test_timestamp", 1, timestamp)
5551
self.mock_metric_lambda_stats.distribution.assert_has_calls(
5652
[call("test_timestamp", 1, timestamp=timestamp, tags=[dd_lambda_layer_tag])]
5753
)
58-
self.mock_metric_extension_thread_stats.distribution.assert_not_called()
5954

6055
@patch("datadog_lambda.metric.should_use_extension", True)
6156
def test_lambda_metric_datetime_with_extension(self):
62-
patcher = patch("datadog_lambda.metric.extension_thread_stats")
63-
self.mock_metric_extension_thread_stats = patcher.start()
64-
self.addCleanup(patcher.stop)
65-
6657
delta = timedelta(minutes=1)
6758
timestamp = datetime.now() - delta
6859

@@ -77,20 +68,14 @@ def test_lambda_metric_datetime_with_extension(self):
7768
)
7869
]
7970
)
80-
self.mock_metric_extension_thread_stats.distribution.assert_not_called()
8171

8272
@patch("datadog_lambda.metric.should_use_extension", True)
8373
def test_lambda_metric_invalid_timestamp_with_extension(self):
84-
patcher = patch("datadog_lambda.metric.extension_thread_stats")
85-
self.mock_metric_extension_thread_stats = patcher.start()
86-
self.addCleanup(patcher.stop)
87-
8874
delta = timedelta(hours=5)
8975
timestamp = int((datetime.now() - delta).timestamp())
9076

9177
lambda_metric("test_timestamp", 1, timestamp)
9278
self.mock_metric_lambda_stats.distribution.assert_not_called()
93-
self.mock_metric_extension_thread_stats.distribution.assert_not_called()
9479

9580
def test_lambda_metric_flush_to_log(self):
9681
os.environ["DD_FLUSH_TO_LOG"] = "True"
@@ -135,10 +120,6 @@ def setUp(self):
135120
self.mock_threadstats_flush_distributions = patcher.start()
136121
self.addCleanup(patcher.stop)
137122

138-
patcher = patch("datadog_lambda.metric.extension_thread_stats")
139-
self.mock_extension_thread_stats = patcher.start()
140-
self.addCleanup(patcher.stop)
141-
142123
def test_retry_on_remote_disconnected(self):
143124
# Raise the RemoteDisconnected error
144125
lambda_stats = ThreadStatsWriter(True)
@@ -217,10 +198,6 @@ def test_flush_temp_constant_tags(self):
217198
lambda_stats.thread_stats.constant_tags, original_constant_tags
218199
)
219200

220-
def test_flush_stats_without_context(self):
221-
flush_stats(lambda_context=None)
222-
self.mock_extension_thread_stats.flush.assert_called_with(None)
223-
224201

225202
MOCK_FUNCTION_NAME = "myFunction"
226203

0 commit comments

Comments
 (0)