@@ -106,6 +106,8 @@ def lambda_handler(event, context):
106106 del os .environ ["DD_LOGS_INJECTION" ]
107107
108108 def test_invocations_metric (self ):
109+ os .environ ["DD_ENHANCED_METRICS" ] = "True"
110+
109111 @datadog_lambda_wrapper
110112 def lambda_handler (event , context ):
111113 lambda_metric ("test.metric" , 100 )
@@ -129,7 +131,11 @@ def lambda_handler(event, context):
129131 ]
130132 )
131133
134+ del os .environ ["DD_ENHANCED_METRICS" ]
135+
132136 def test_errors_metric (self ):
137+ os .environ ["DD_ENHANCED_METRICS" ] = "True"
138+
133139 @datadog_lambda_wrapper
134140 def lambda_handler (event , context ):
135141 raise RuntimeError ()
@@ -164,7 +170,11 @@ def lambda_handler(event, context):
164170 ]
165171 )
166172
173+ del os .environ ["DD_ENHANCED_METRICS" ]
174+
167175 def test_enhanced_metrics_cold_start_tag (self ):
176+ os .environ ["DD_ENHANCED_METRICS" ] = "True"
177+
168178 @datadog_lambda_wrapper
169179 def lambda_handler (event , context ):
170180 lambda_metric ("test.metric" , 100 )
@@ -203,3 +213,18 @@ def lambda_handler(event, context):
203213 ),
204214 ]
205215 )
216+
217+ del os .environ ["DD_ENHANCED_METRICS" ]
218+
219+ def test_no_enhanced_metrics_without_env_var (self ):
220+ @datadog_lambda_wrapper
221+ def lambda_handler (event , context ):
222+ raise RuntimeError ()
223+
224+ lambda_event = {}
225+
226+ with self .assertRaises (RuntimeError ):
227+ lambda_handler (lambda_event , get_mock_context ())
228+
229+ self .mock_wrapper_lambda_metric .assert_not_called ()
230+
0 commit comments