Skip to content

Commit c7c2fe9

Browse files
committed
feat(tracing): Add span links from SNS messages
1 parent dd6d779 commit c7c2fe9

File tree

1 file changed

+9
-0
lines changed
  • elasticapm/contrib/serverless

1 file changed

+9
-0
lines changed

elasticapm/contrib/serverless/aws.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,20 @@ def __enter__(self):
235235
transaction_name = "RECEIVE {}".format(record["eventSourceARN"].split(":")[5])
236236

237237
if "Records" in self.event:
238+
# SQS
238239
links = [
239240
TraceParent.from_string(record["messageAttributes"]["traceparent"]["stringValue"])
240241
for record in self.event["Records"][:1000]
241242
if "messageAttributes" in record and "traceparent" in record["messageAttributes"]
242243
]
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+
]
243252
else:
244253
links = []
245254

0 commit comments

Comments
 (0)