@@ -14,11 +14,13 @@ def get_mock_context(
1414 aws_request_id = "request-id-1" ,
1515 memory_limit_in_mb = "256" ,
1616 invoked_function_arn = "arn:aws:lambda:us-west-1:123457598159:function:python-layer-test" ,
17+ function_version = "1" ,
1718):
1819 lambda_context = MagicMock ()
1920 lambda_context .aws_request_id = aws_request_id
2021 lambda_context .memory_limit_in_mb = memory_limit_in_mb
2122 lambda_context .invoked_function_arn = invoked_function_arn
23+ lambda_context .function_version = function_version
2224 return lambda_context
2325
2426
@@ -146,6 +148,7 @@ def lambda_handler(event, context):
146148 "functionname:python-layer-test" ,
147149 "cold_start:true" ,
148150 "memorysize:256" ,
151+ "executedversion:1" ,
149152 "runtime:python2.7" ,
150153 "dd_lambda_layer:datadog-python27_0.1.0" ,
151154 ],
@@ -174,6 +177,7 @@ def lambda_handler(event, context):
174177 "functionname:python-layer-test" ,
175178 "cold_start:true" ,
176179 "memorysize:256" ,
180+ "executedversion:1" ,
177181 "runtime:python2.7" ,
178182 "dd_lambda_layer:datadog-python27_0.1.0" ,
179183 ],
@@ -187,13 +191,49 @@ def lambda_handler(event, context):
187191 "functionname:python-layer-test" ,
188192 "cold_start:true" ,
189193 "memorysize:256" ,
194+ "executedversion:1" ,
190195 "runtime:python2.7" ,
191196 "dd_lambda_layer:datadog-python27_0.1.0" ,
192197 ],
193198 ),
194199 ]
195200 )
196201
202+ def test_metric_with_function_alias (self ):
203+ @datadog_lambda_wrapper
204+ def lambda_handler (event , context ):
205+ lambda_metric ("test.meetric" , 100 )
206+
207+ invoked_function_with_alias = (
208+ "arn:aws:lambda:us-west-1:123457598159:function:python-layer-test:foobar"
209+ )
210+
211+ lambda_event = {}
212+ lambda_context = get_mock_context ()
213+ lambda_context .invoked_function_arn = invoked_function_with_alias
214+
215+ lambda_handler (lambda_event , lambda_context )
216+
217+ self .mock_write_metric_point_to_stdout .assert_has_calls (
218+ [
219+ call (
220+ "aws.lambda.enhanced.invocations" ,
221+ 1 ,
222+ tags = [
223+ "region:us-west-1" ,
224+ "account_id:123457598159" ,
225+ "functionname:python-layer-test" ,
226+ "resource:python-layer-test:foobar" ,
227+ "cold_start:true" ,
228+ "memorysize:256" ,
229+ "executedversion:1" ,
230+ "runtime:python2.7" ,
231+ "dd_lambda_layer:datadog-python27_0.1.0" ,
232+ ],
233+ )
234+ ]
235+ )
236+
197237 def test_enhanced_metrics_cold_start_tag (self ):
198238 @datadog_lambda_wrapper
199239 def lambda_handler (event , context ):
@@ -220,6 +260,7 @@ def lambda_handler(event, context):
220260 "functionname:python-layer-test" ,
221261 "cold_start:true" ,
222262 "memorysize:256" ,
263+ "executedversion:1" ,
223264 "runtime:python2.7" ,
224265 "dd_lambda_layer:datadog-python27_0.1.0" ,
225266 ],
@@ -233,6 +274,7 @@ def lambda_handler(event, context):
233274 "functionname:python-layer-test" ,
234275 "cold_start:false" ,
235276 "memorysize:256" ,
277+ "executedversion:1" ,
236278 "runtime:python2.7" ,
237279 "dd_lambda_layer:datadog-python27_0.1.0" ,
238280 ],
0 commit comments