Skip to content

Commit ddf0fe6

Browse files
committed
Added transaction source and tests for AWS lambda
1 parent 1e0009b commit ddf0fe6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sentry_sdk/integrations/aws_lambda.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from sentry_sdk.tracing import Transaction
77
from sentry_sdk._compat import reraise
88
from sentry_sdk.utils import (
9+
TRANSACTION_SOURCE_COMPONENT,
910
AnnotatedValue,
1011
capture_internal_exceptions,
1112
event_from_exception,
@@ -139,7 +140,10 @@ def sentry_handler(aws_event, aws_context, *args, **kwargs):
139140
if headers is None:
140141
headers = {}
141142
transaction = Transaction.continue_from_headers(
142-
headers, op="serverless.function", name=aws_context.function_name
143+
headers,
144+
op="serverless.function",
145+
name=aws_context.function_name,
146+
source=TRANSACTION_SOURCE_COMPONENT,
143147
)
144148
with hub.start_transaction(
145149
transaction,

tests/integrations/aws_lambda/test_aws.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ def test_handler(event, context):
362362
assert envelope["type"] == "transaction"
363363
assert envelope["contexts"]["trace"]["op"] == "serverless.function"
364364
assert envelope["transaction"].startswith("test_function_")
365+
assert envelope["transaction_info"] == {"source": "component"}
365366
assert envelope["transaction"] in envelope["request"]["url"]
366367

367368

@@ -390,6 +391,7 @@ def test_handler(event, context):
390391
assert envelope["type"] == "transaction"
391392
assert envelope["contexts"]["trace"]["op"] == "serverless.function"
392393
assert envelope["transaction"].startswith("test_function_")
394+
assert envelope["transaction_info"] == {"source": "component"}
393395
assert envelope["transaction"] in envelope["request"]["url"]
394396

395397

0 commit comments

Comments
 (0)