@@ -14,11 +14,13 @@ def get_mock_context(
14
14
aws_request_id = "request-id-1" ,
15
15
memory_limit_in_mb = "256" ,
16
16
invoked_function_arn = "arn:aws:lambda:us-west-1:123457598159:function:python-layer-test" ,
17
+ function_version = "1" ,
17
18
):
18
19
lambda_context = MagicMock ()
19
20
lambda_context .aws_request_id = aws_request_id
20
21
lambda_context .memory_limit_in_mb = memory_limit_in_mb
21
22
lambda_context .invoked_function_arn = invoked_function_arn
23
+ lambda_context .function_version = function_version
22
24
return lambda_context
23
25
24
26
@@ -146,6 +148,7 @@ def lambda_handler(event, context):
146
148
"functionname:python-layer-test" ,
147
149
"cold_start:true" ,
148
150
"memorysize:256" ,
151
+ "executedversion:1" ,
149
152
"runtime:python2.7" ,
150
153
"dd_lambda_layer:datadog-python27_0.1.0" ,
151
154
],
@@ -174,6 +177,7 @@ def lambda_handler(event, context):
174
177
"functionname:python-layer-test" ,
175
178
"cold_start:true" ,
176
179
"memorysize:256" ,
180
+ "executedversion:1" ,
177
181
"runtime:python2.7" ,
178
182
"dd_lambda_layer:datadog-python27_0.1.0" ,
179
183
],
@@ -187,13 +191,49 @@ def lambda_handler(event, context):
187
191
"functionname:python-layer-test" ,
188
192
"cold_start:true" ,
189
193
"memorysize:256" ,
194
+ "executedversion:1" ,
190
195
"runtime:python2.7" ,
191
196
"dd_lambda_layer:datadog-python27_0.1.0" ,
192
197
],
193
198
),
194
199
]
195
200
)
196
201
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
+
197
237
def test_enhanced_metrics_cold_start_tag (self ):
198
238
@datadog_lambda_wrapper
199
239
def lambda_handler (event , context ):
@@ -220,6 +260,7 @@ def lambda_handler(event, context):
220
260
"functionname:python-layer-test" ,
221
261
"cold_start:true" ,
222
262
"memorysize:256" ,
263
+ "executedversion:1" ,
223
264
"runtime:python2.7" ,
224
265
"dd_lambda_layer:datadog-python27_0.1.0" ,
225
266
],
@@ -233,6 +274,7 @@ def lambda_handler(event, context):
233
274
"functionname:python-layer-test" ,
234
275
"cold_start:false" ,
235
276
"memorysize:256" ,
277
+ "executedversion:1" ,
236
278
"runtime:python2.7" ,
237
279
"dd_lambda_layer:datadog-python27_0.1.0" ,
238
280
],
0 commit comments