File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
elasticapm/contrib/serverless Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -235,11 +235,20 @@ def __enter__(self):
235
235
transaction_name = "RECEIVE {}" .format (record ["eventSourceARN" ].split (":" )[5 ])
236
236
237
237
if "Records" in self .event :
238
+ # SQS
238
239
links = [
239
240
TraceParent .from_string (record ["messageAttributes" ]["traceparent" ]["stringValue" ])
240
241
for record in self .event ["Records" ][:1000 ]
241
242
if "messageAttributes" in record and "traceparent" in record ["messageAttributes" ]
242
243
]
244
+ # SNS
245
+ links += [
246
+ TraceParent .from_string (record ["Sns" ]["MessageAttributes" ]["traceparent" ]["Value" ])
247
+ for record in self .event ["Records" ][:1000 ]
248
+ if "Sns" in record
249
+ and "MessageAttributes" in record ["Sns" ]
250
+ and "traceparent" in record ["Sns" ]["MessageAttributes" ]
251
+ ]
243
252
else :
244
253
links = []
245
254
Original file line number Diff line number Diff line change 27
27
"City" : {
28
28
"Type" : " String" ,
29
29
"Value" : " Any City"
30
+ },
31
+ "traceparent" : {
32
+ "Type" : " String" ,
33
+ "Value" : " 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-00"
30
34
}
31
35
}
32
36
}
Original file line number Diff line number Diff line change @@ -344,6 +344,8 @@ def test_func(event, context):
344
344
assert transaction ["span_count" ]["started" ] == 1
345
345
assert transaction ["context" ]["message" ]["headers" ]["Population" ] == "1250800"
346
346
assert transaction ["context" ]["message" ]["headers" ]["City" ] == "Any City"
347
+ assert len (transaction ["links" ]) == 1
348
+ assert transaction ["links" ][0 ] == {"trace_id" : "0af7651916cd43dd8448eb211c80319c" , "span_id" : "b7ad6b7169203331" }
347
349
348
350
349
351
def test_capture_serverless_sqs (event_sqs , context , elasticapm_client ):
You can’t perform that action at this time.
0 commit comments