Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions sentry_sdk/integrations/aws_lambda/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ def sentry_handler(

if isinstance(aws_event, list) and len(aws_event) >= 1:
request_data = aws_event[0]
batch_size = len(aws_event)
else:
request_data = aws_event
batch_size = 1

if not isinstance(request_data, dict):
# If we're not dealing with a dictionary, we won't be able to get
Expand Down Expand Up @@ -160,7 +158,6 @@ def sentry_handler(
SPANDATA.SENTRY_SEGMENT_NAME_SOURCE: SegmentNameSource.COMPONENT,
SPANDATA.CLOUD_PROVIDER: CLOUD_PROVIDER,
SPANDATA.CLOUD_PLATFORM: CLOUD_PLATFORM,
SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT: batch_size,
**header_attributes,
**additional_attributes,
}
Expand Down
22 changes: 9 additions & 13 deletions tests/integrations/aws_lambda/test_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ def test_timeout_error_scope_modified(lambda_client, test_environment):


@pytest.mark.parametrize(
"aws_event, has_request_data, batch_size",
"aws_event, has_request_data",
[
(b"1231", False, 1),
(b"11.21", False, 1),
(b'"Good dog!"', False, 1),
(b"true", False, 1),
(b"1231", False),
(b"11.21", False),
(b'"Good dog!"', False),
(b"true", False),
(
b"""
[
Expand All @@ -175,7 +175,6 @@ def test_timeout_error_scope_modified(lambda_client, test_environment):
]
""",
False,
4,
),
(
b"""
Expand Down Expand Up @@ -207,9 +206,8 @@ def test_timeout_error_scope_modified(lambda_client, test_environment):
]
""",
True,
2,
),
(b"[]", False, 1),
(b"[]", False),
],
ids=[
"event as integer",
Expand All @@ -221,9 +219,7 @@ def test_timeout_error_scope_modified(lambda_client, test_environment):
"event as empty list",
],
)
def test_non_dict_event(
lambda_client, test_environment, aws_event, has_request_data, batch_size
):
def test_non_dict_event(lambda_client, test_environment, aws_event, has_request_data):
lambda_client.invoke(
FunctionName="BasicException",
Payload=aws_event,
Expand Down Expand Up @@ -756,7 +752,7 @@ def test_no_error(lambda_client, test_environment):
assert _get_span_attr(attrs, SPANDATA.AWS_LOG_STREAM_NAMES) == [
LATEST_FUNCTION_VERSION
]
assert _get_span_attr(attrs, SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT) == 1
assert SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT not in attrs


def test_error(lambda_client, test_environment):
Expand Down Expand Up @@ -810,7 +806,7 @@ def test_error(lambda_client, test_environment):
assert _get_span_attr(attrs, SPANDATA.AWS_LOG_STREAM_NAMES) == [
LATEST_FUNCTION_VERSION
]
assert _get_span_attr(attrs, SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT) == 1
assert SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT not in attrs


def test_trace_continuation(lambda_client, test_environment):
Expand Down
Loading