33# This product includes software developed at Datadog (https://www.datadoghq.com/).
44# Copyright 2019 Datadog, Inc.
55
6+ import logging
67import os
78import time
8- import logging
9- import ujson as json
109from datetime import datetime , timedelta
1110
11+ import ujson as json
12+
1213from datadog_lambda .extension import should_use_extension
13- from datadog_lambda .tags import get_enhanced_metrics_tags , dd_lambda_layer_tag
14+ from datadog_lambda .tags import dd_lambda_layer_tag , get_enhanced_metrics_tags
1415
1516logger = logging .getLogger (__name__ )
1617
2829 # and leads to data loss. When disabled, metrics are only flushed at the
2930 # end of invocation. To make metrics submitted from a long-running Lambda
3031 # function available sooner, consider using the Datadog Lambda extension.
31- from datadog_lambda .thread_stats_writer import ThreadStatsWriter
3232 from datadog_lambda .api import init_api
33+ from datadog_lambda .thread_stats_writer import ThreadStatsWriter
3334
3435 init_api ()
3536 lambda_stats = ThreadStatsWriter (flush_in_thread )
@@ -92,8 +93,8 @@ def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=Fal
9293 return
9394 global extension_thread_stats
9495 if extension_thread_stats is None :
95- from datadog_lambda .thread_stats_writer import ThreadStatsWriter
9696 from datadog_lambda .api import init_api
97+ from datadog_lambda .thread_stats_writer import ThreadStatsWriter
9798
9899 init_api ()
99100 extension_thread_stats = ThreadStatsWriter (flush_in_thread )
@@ -119,8 +120,10 @@ def lambda_metric(metric_name, value, timestamp=None, tags=None, force_async=Fal
119120 )
120121
121122
122- def write_metric_point_to_stdout (metric_name , value , timestamp = None , tags = [] ):
123+ def write_metric_point_to_stdout (metric_name , value , timestamp = None , tags = None ):
123124 """Writes the specified metric point to standard output"""
125+ tags = tags or []
126+
124127 logger .debug (
125128 "Sending metric %s value %s to Datadog via log forwarder" , metric_name , value
126129 )
0 commit comments