From 9fff243d173502135f0243cd999f920146c31dff Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Fri, 9 Oct 2026 11:04:30 +0200 Subject: [PATCH 1/3] ref(aws-lambda): consts, f-strings, move into dir --- scripts/build_aws_lambda_layer.py | 6 +- sentry_sdk/consts.py | 79 +++++++++ sentry_sdk/integrations/aws_lambda/consts.py | 8 + .../aws_lambda/test_aws_lambda.py | 158 +++++++++++------- 4 files changed, 184 insertions(+), 67 deletions(-) diff --git a/scripts/build_aws_lambda_layer.py b/scripts/build_aws_lambda_layer.py index 9929044ff3..fbdb2f4a6f 100644 --- a/scripts/build_aws_lambda_layer.py +++ b/scripts/build_aws_lambda_layer.py @@ -113,9 +113,9 @@ def build_packaged_zip(base_dir=None, out_zip_filename=None): # Just for debugging dist_path = os.path.abspath(DIST_PATH) print("Created Lambda Layer package with this information:") - print(" - Base directory for generating package: {}".format(layer_builder.base_dir)) - print(" - Package zip filename: {}".format(layer_builder.out_zip_filename)) - print(" - Copied package zip to: {}".format(dist_path)) + print(f" - Base directory for generating package: {layer_builder.base_dir}") + print(f" - Package zip filename: {layer_builder.out_zip_filename}") + print(f" - Copied package zip to: {dist_path}") if __name__ == "__main__": diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index 5b037a66d0..3f3940abbb 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -396,6 +396,24 @@ class SPANDATA: Example: "wzHcyEWfmOGDIE5QOhTAqFDoDWP3y8IUvpNINCwL9N4TEHbUw0/gZJ+VZTmCNCWR7fezEN3eCiQ=" """ + AWS_LAMBDA_INVOKED_ARN = "aws.lambda.invoked_arn" + """ + The full ARN of the Lambda function that was invoked. + Example: "arn:aws:lambda:us-east-1:123456789012:function:my-function" + """ + + AWS_LOG_GROUP_NAMES = "aws.log.group.names" + """ + The name(s) of the AWS log group(s) an application is writing to. + Example: ["/aws/lambda/my-function", "opentelemetry-service"] + """ + + AWS_LOG_STREAM_NAMES = "aws.log.stream.names" + """ + The name(s) of the AWS log stream(s) an application is writing to. + Example: ["logs/main/10838bed-421f-43ef-870a-f43feacbbb5b"] + """ + AWS_REQUEST_ID = "aws.request_id" """ The AWS request ID as returned in the response headers. @@ -426,12 +444,43 @@ class SPANDATA: Example: "10.1.2.80" """ + CLOUD_ACCOUNT_ID = "cloud.account.id" + """ + The cloud account ID the resource is assigned to. + Example: "123456789012" + """ + + CLOUD_AVAILABILITY_ZONE = "cloud.availability_zone" + """ + Cloud regions often have multiple, isolated locations known as zones to increase availability + Example: "us-east-1c" + """ + + CLOUD_PLATFORM = "cloud.platform" + """ + The cloud platform in use. + Example: "aws_lambda" + """ + + CLOUD_PROVIDER = "cloud.provider" + """ + Name of the cloud provider. + + Example: "aws" + """ + CLOUD_REGION = "cloud.region" """ The geographical region the resource is running. Example: "us-east-1" """ + CLOUD_RESOURCE_ID = "cloud.resource_id" + """ + Cloud provider-specific native identifier of the monitored cloud resource + Example: "arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function" + """ + CODE_FILEPATH = "code.filepath" """ .. deprecated:: @@ -565,6 +614,24 @@ class SPANDATA: Example: "timeout" """ + FAAS_INVOCATION_ID = "faas.invocation_id" + """ + The invocation ID of the current function invocation. + Example: "af9d5aa4-a685-4c5f-a22b-444f80b3cc28" + """ + + FAAS_NAME = "faas.name" + """ + The name of the serverless function. + Example: "my_function" + """ + + FAAS_VERSION = "faas.version" + """ + The version of the function that was invoked. + Example: "$LATEST" + """ + GEN_AI_AGENT_NAME = "gen_ai.agent.name" """ The name of the agent being used. @@ -928,6 +995,12 @@ class SPANDATA: Example: 418 """ + MESSAGING_BATCH_MESSAGE_COUNT = "messaging.batch.message_count" + """ + The number of messages sent, received, or processed in the scope of the batching operation. + Example: 10 + """ + MESSAGING_DESTINATION_NAME = "messaging.destination.name" """ The destination name where the message is being consumed from, @@ -1262,6 +1335,12 @@ class SPANDATA: Example: ["AtexitIntegration", "StdlibIntegration"] """ + SENTRY_SEGMENT_NAME_SOURCE = "sentry.segment.name.source" + """ + The source of the segment span name. Should only be set on segment spans. + Example: "route", "component", "view", "task", "custom", "url" + """ + USER_AGENT_ORIGINAL = "user_agent.original" """ Value of the HTTP User-Agent header sent by the client. diff --git a/sentry_sdk/integrations/aws_lambda/consts.py b/sentry_sdk/integrations/aws_lambda/consts.py index 5a447ca231..df7018bbb9 100644 --- a/sentry_sdk/integrations/aws_lambda/consts.py +++ b/sentry_sdk/integrations/aws_lambda/consts.py @@ -1,6 +1,14 @@ IDENTIFIER = "aws_lambda" ORIGIN = f"auto.function.{IDENTIFIER}" +CLOUD_PROVIDER = "aws" +CLOUD_PLATFORM = "aws_lambda" +SENTRY_KIND = "server" +LATEST_FUNCTION_VERSION = "$LATEST" + # buffer time time required to send timeout warning. TIMEOUT_WARNING_BUFFER = 1500 MILLIS_TO_SECONDS = 1000.0 + +LAMBDA_METADATA_PATH = "/2026-01-15/metadata/execution-environment" +LAMBDA_METADATA_TIMEOUT = 0.5 diff --git a/tests/integrations/aws_lambda/test_aws_lambda.py b/tests/integrations/aws_lambda/test_aws_lambda.py index 0bf1cd3670..ae6216d99a 100644 --- a/tests/integrations/aws_lambda/test_aws_lambda.py +++ b/tests/integrations/aws_lambda/test_aws_lambda.py @@ -10,6 +10,17 @@ import yaml from aws_cdk import App +from sentry_sdk.consts import OP, SPANDATA +from sentry_sdk.integrations.aws_lambda.consts import ( + CLOUD_PLATFORM, + CLOUD_PROVIDER, + IDENTIFIER, + LATEST_FUNCTION_VERSION, + ORIGIN, + SENTRY_KIND, +) +from sentry_sdk.traces import SegmentNameSource + from .utils import SAM_PORT, LocalLambdaStack, SentryServerForTesting DOCKER_NETWORK_NAME = "lambda-test-network" @@ -130,17 +141,17 @@ def test_basic_no_exception(lambda_client, test_environment): "aws_request_id": mock.ANY, "execution_duration_in_millis": mock.ANY, "function_name": "BasicOk", - "function_version": "$LATEST", + "function_version": LATEST_FUNCTION_VERSION, "invoked_function_arn": "arn:aws:lambda:us-east-1:012345678912:function:BasicOk", "remaining_time_in_millis": mock.ANY, } assert transaction_event["contexts"]["trace"] == { - "op": "function.aws", + "op": OP.FUNCTION_AWS, "description": mock.ANY, "span_id": mock.ANY, "parent_span_id": mock.ANY, "trace_id": mock.ANY, - "origin": "auto.function.aws_lambda", + "origin": ORIGIN, "data": mock.ANY, } @@ -171,17 +182,17 @@ def test_basic_exception(lambda_client, test_environment): "aws_request_id": mock.ANY, "execution_duration_in_millis": mock.ANY, "function_name": "BasicException", - "function_version": "$LATEST", + "function_version": LATEST_FUNCTION_VERSION, "invoked_function_arn": "arn:aws:lambda:us-east-1:012345678912:function:BasicException", "remaining_time_in_millis": mock.ANY, } assert error_event["contexts"]["trace"] == { - "op": "function.aws", + "op": OP.FUNCTION_AWS, "description": mock.ANY, "span_id": mock.ANY, "parent_span_id": mock.ANY, "trace_id": mock.ANY, - "origin": "auto.function.aws_lambda", + "origin": ORIGIN, "data": mock.ANY, } @@ -310,7 +321,7 @@ def test_non_dict_event( assert error_event["sdk"]["name"] == "sentry.python.aws_lambda" assert error_event["exception"]["values"][0]["type"] == "RuntimeError" assert error_event["exception"]["values"][0]["value"] == "Oh!" - assert error_event["exception"]["values"][0]["mechanism"]["type"] == "aws_lambda" + assert error_event["exception"]["values"][0]["mechanism"]["type"] == IDENTIFIER if has_request_data: request_data = { @@ -809,7 +820,7 @@ def test_trace_continuation(lambda_client, test_environment): trace_id = "471a43a4192642f0b136d5159a501701" parent_span_id = "6e8f22c393e68f19" parent_sampled = 1 - sentry_trace_header = "{}-{}-{}".format(trace_id, parent_span_id, parent_sampled) + sentry_trace_header = f"{trace_id}-{parent_span_id}-{parent_sampled}" # We simulate here AWS Api Gateway's behavior of passing HTTP headers # as the `headers` dict in the event passed to the Lambda function. @@ -874,9 +885,7 @@ def test_span_origin(lambda_client, test_environment): (transaction_event,) = envelopes - assert ( - transaction_event["contexts"]["trace"]["origin"] == "auto.function.aws_lambda" - ) + assert transaction_event["contexts"]["trace"]["origin"] == ORIGIN def test_traces_sampler_has_correct_sampling_context(lambda_client, test_environment): @@ -955,28 +964,35 @@ def test_span_streaming_no_error(lambda_client, test_environment): attrs = segment_span["attributes"] - assert _get_span_attr(attrs, "sentry.op") == "function.aws" - assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" - assert _get_span_attr(attrs, "cloud.provider") == "aws" - assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" + assert _get_span_attr(attrs, SPANDATA.SENTRY_OP) == OP.FUNCTION_AWS + assert _get_span_attr(attrs, SPANDATA.SENTRY_ORIGIN) == ORIGIN + assert _get_span_attr(attrs, SPANDATA.SENTRY_KIND) == SENTRY_KIND assert ( - _get_span_attr(attrs, "cloud.resource_id") + _get_span_attr(attrs, SPANDATA.SENTRY_SEGMENT_NAME_SOURCE) + == SegmentNameSource.COMPONENT + ) + assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER + assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM + assert _get_span_attr(attrs, SPANDATA.CLOUD_ACCOUNT_ID) == "012345678912" + assert ( + _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) == "arn:aws:lambda:us-east-1:012345678912:function:BasicOkSpanStreaming" ) - assert _get_span_attr(attrs, "cloud.region") == "us-east-1" - assert _get_span_attr(attrs, "faas.name") == "BasicOkSpanStreaming" - assert _get_span_attr(attrs, "faas.version") == "$LATEST" - assert "faas.invocation_id" in attrs + assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" + assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "BasicOkSpanStreaming" + assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION + assert SPANDATA.FAAS_INVOCATION_ID in attrs assert ( - _get_span_attr(attrs, "aws.lambda.invoked_arn") + _get_span_attr(attrs, SPANDATA.AWS_LAMBDA_INVOKED_ARN) == "arn:aws:lambda:us-east-1:012345678912:function:BasicOkSpanStreaming" ) - assert _get_span_attr(attrs, "aws.log.group.names") == [ + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_GROUP_NAMES) == [ "aws/lambda/BasicOkSpanStreaming" ] - assert _get_span_attr(attrs, "aws.log.stream.names") == ["$LATEST"] - assert _get_span_attr(attrs, "messaging.batch.message_count") == 1 + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_STREAM_NAMES) == [ + LATEST_FUNCTION_VERSION + ] + assert _get_span_attr(attrs, SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT) == 1 def test_span_streaming_error(lambda_client, test_environment): @@ -993,7 +1009,7 @@ def test_span_streaming_error(lambda_client, test_environment): (exception,) = error_event["exception"]["values"] assert exception["type"] == "Exception" assert exception["value"] == "Oh!" - assert exception["mechanism"]["type"] == "aws_lambda" + assert exception["mechanism"]["type"] == IDENTIFIER assert not exception["mechanism"]["handled"] segment_spans = [s for s in span_items if s["is_segment"]] @@ -1005,35 +1021,40 @@ def test_span_streaming_error(lambda_client, test_environment): attrs = segment_span["attributes"] - assert _get_span_attr(attrs, "sentry.op") == "function.aws" - assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" - assert _get_span_attr(attrs, "cloud.provider") == "aws" - assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" + assert _get_span_attr(attrs, SPANDATA.SENTRY_OP) == OP.FUNCTION_AWS + assert _get_span_attr(attrs, SPANDATA.SENTRY_ORIGIN) == ORIGIN assert ( - _get_span_attr(attrs, "cloud.resource_id") + _get_span_attr(attrs, SPANDATA.SENTRY_SEGMENT_NAME_SOURCE) + == SegmentNameSource.COMPONENT + ) + assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER + assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM + assert ( + _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) == "arn:aws:lambda:us-east-1:012345678912:function:RaiseErrorSpanStreaming" ) - assert _get_span_attr(attrs, "cloud.region") == "us-east-1" - assert _get_span_attr(attrs, "faas.name") == "RaiseErrorSpanStreaming" - assert _get_span_attr(attrs, "faas.version") == "$LATEST" - assert "faas.invocation_id" in attrs + assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" + assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "RaiseErrorSpanStreaming" + assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION + assert SPANDATA.FAAS_INVOCATION_ID in attrs assert ( - _get_span_attr(attrs, "aws.lambda.invoked_arn") + _get_span_attr(attrs, SPANDATA.AWS_LAMBDA_INVOKED_ARN) == "arn:aws:lambda:us-east-1:012345678912:function:RaiseErrorSpanStreaming" ) - assert _get_span_attr(attrs, "aws.log.group.names") == [ + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_GROUP_NAMES) == [ "aws/lambda/RaiseErrorSpanStreaming" ] - assert _get_span_attr(attrs, "aws.log.stream.names") == ["$LATEST"] - assert _get_span_attr(attrs, "messaging.batch.message_count") == 1 + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_STREAM_NAMES) == [ + LATEST_FUNCTION_VERSION + ] + assert _get_span_attr(attrs, SPANDATA.MESSAGING_BATCH_MESSAGE_COUNT) == 1 def test_span_streaming_trace_continuation(lambda_client, test_environment): trace_id = "471a43a4192642f0b136d5159a501701" parent_span_id = "6e8f22c393e68f19" parent_sampled = 1 - sentry_trace_header = "{}-{}-{}".format(trace_id, parent_span_id, parent_sampled) + sentry_trace_header = f"{trace_id}-{parent_span_id}-{parent_sampled}" payload = { "headers": { @@ -1058,15 +1079,18 @@ def test_span_streaming_trace_continuation(lambda_client, test_environment): assert segment_span["trace_id"] == trace_id assert segment_span["name"] == "RaiseErrorSpanStreaming" attrs = segment_span["attributes"] - assert _get_span_attr(attrs, "sentry.op") == "function.aws" - assert _get_span_attr(attrs, "sentry.origin") == "auto.function.aws_lambda" - assert _get_span_attr(attrs, "sentry.segment.name.source") == "component" - assert _get_span_attr(attrs, "cloud.provider") == "aws" - assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" - assert _get_span_attr(attrs, "cloud.region") == "us-east-1" - assert _get_span_attr(attrs, "faas.name") == "RaiseErrorSpanStreaming" - assert _get_span_attr(attrs, "faas.version") == "$LATEST" - assert "faas.invocation_id" in attrs + assert _get_span_attr(attrs, SPANDATA.SENTRY_OP) == OP.FUNCTION_AWS + assert _get_span_attr(attrs, SPANDATA.SENTRY_ORIGIN) == ORIGIN + assert ( + _get_span_attr(attrs, SPANDATA.SENTRY_SEGMENT_NAME_SOURCE) + == SegmentNameSource.COMPONENT + ) + assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER + assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM + assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" + assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "RaiseErrorSpanStreaming" + assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION + assert SPANDATA.FAAS_INVOCATION_ID in attrs def test_span_streaming_request_attributes(lambda_client, test_environment): @@ -1091,25 +1115,31 @@ def test_span_streaming_request_attributes(lambda_client, test_environment): segment_span = segment_spans[0] attrs = segment_span["attributes"] - assert _get_span_attr(attrs, "http.request.method") == "POST" + assert _get_span_attr(attrs, SPANDATA.HTTP_REQUEST_METHOD) == "POST" assert ( - _get_span_attr(attrs, "url.query") + _get_span_attr(attrs, SPANDATA.URL_QUERY) == "foo=bar&a-complicated-value=a%3Db%26c%3Dd" ) assert ( - _get_span_attr(attrs, "http.request.header.content-type") == "application/json" + _get_span_attr(attrs, f"{SPANDATA.HTTP_REQUEST_HEADER}.content-type") + == "application/json" ) - assert _get_span_attr(attrs, "http.request.header.accept") == "text/html" - assert _get_span_attr(attrs, "faas.name") == "BasicOkSpanStreamingPii" - assert _get_span_attr(attrs, "cloud.provider") == "aws" - assert _get_span_attr(attrs, "cloud.platform") == "aws_lambda" - assert _get_span_attr(attrs, "cloud.region") == "us-east-1" - assert _get_span_attr(attrs, "faas.version") == "$LATEST" - assert "faas.invocation_id" in attrs - assert _get_span_attr(attrs, "aws.log.group.names") == [ + assert ( + _get_span_attr(attrs, f"{SPANDATA.HTTP_REQUEST_HEADER}.accept") == "text/html" + ) + assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "BasicOkSpanStreamingPii" + assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER + assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM + assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" + assert _get_span_attr(attrs, SPANDATA.CLOUD_AVAILABILITY_ZONE) == "use1-az1" + assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION + assert SPANDATA.FAAS_INVOCATION_ID in attrs + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_GROUP_NAMES) == [ "aws/lambda/BasicOkSpanStreamingPii" ] - assert _get_span_attr(attrs, "aws.log.stream.names") == ["$LATEST"] + assert _get_span_attr(attrs, SPANDATA.AWS_LOG_STREAM_NAMES) == [ + LATEST_FUNCTION_VERSION + ] def test_span_streaming_url_query_params_with_data_collection( @@ -1139,7 +1169,7 @@ def test_span_streaming_url_query_params_with_data_collection( # "page" passes through; "tracking" is denied by a custom term and "token" # by the built-in sensitive denylist. assert ( - _get_span_attr(attrs, "url.query") + _get_span_attr(attrs, SPANDATA.URL_QUERY) == "page=2&tracking=%5BFiltered%5D&token=%5BFiltered%5D" ) @@ -1228,7 +1258,7 @@ def test_error_has_existing_trace_context( trace_id = "471a43a4192642f0b136d5159a501701" parent_span_id = "6e8f22c393e68f19" parent_sampled = 1 - sentry_trace_header = "{}-{}-{}".format(trace_id, parent_span_id, parent_sampled) + sentry_trace_header = f"{trace_id}-{parent_span_id}-{parent_sampled}" # We simulate here AWS Api Gateway's behavior of passing HTTP headers # as the `headers` dict in the event passed to the Lambda function. From 9041f9a85cc5c9ada86c88308c20ddecb5000ebc Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Fri, 9 Oct 2026 13:31:32 +0200 Subject: [PATCH 2/3] ref(aws-lambda): Clean up integration --- sentry_sdk/integrations/aws_lambda/_handler.py | 5 +++-- sentry_sdk/integrations/aws_lambda/consts.py | 4 ---- tests/integrations/aws_lambda/test_aws_lambda.py | 7 ------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/sentry_sdk/integrations/aws_lambda/_handler.py b/sentry_sdk/integrations/aws_lambda/_handler.py index 8c394decc4..cf91faa84b 100644 --- a/sentry_sdk/integrations/aws_lambda/_handler.py +++ b/sentry_sdk/integrations/aws_lambda/_handler.py @@ -15,6 +15,7 @@ ) from sentry_sdk.integrations.aws_lambda.consts import ( MILLIS_TO_SECONDS, + ORIGIN, TIMEOUT_WARNING_BUFFER, ) from sentry_sdk.integrations.cloud_resource_context import ( @@ -171,7 +172,7 @@ def sentry_handler( parent_span=None, attributes={ "sentry.op": OP.FUNCTION_AWS, - "sentry.origin": AwsLambdaIntegration.origin, + "sentry.origin": ORIGIN, "sentry.segment.name.source": SegmentNameSource.COMPONENT, "cloud.region": aws_region, "cloud.resource_id": aws_context.invoked_function_arn, @@ -194,7 +195,7 @@ def sentry_handler( op=OP.FUNCTION_AWS, name=function_name, source=TransactionSource.COMPONENT, - origin=AwsLambdaIntegration.origin, + origin=ORIGIN, ) span_ctx = sentry_sdk.start_transaction( diff --git a/sentry_sdk/integrations/aws_lambda/consts.py b/sentry_sdk/integrations/aws_lambda/consts.py index df7018bbb9..21d10bc026 100644 --- a/sentry_sdk/integrations/aws_lambda/consts.py +++ b/sentry_sdk/integrations/aws_lambda/consts.py @@ -3,12 +3,8 @@ CLOUD_PROVIDER = "aws" CLOUD_PLATFORM = "aws_lambda" -SENTRY_KIND = "server" LATEST_FUNCTION_VERSION = "$LATEST" # buffer time time required to send timeout warning. TIMEOUT_WARNING_BUFFER = 1500 MILLIS_TO_SECONDS = 1000.0 - -LAMBDA_METADATA_PATH = "/2026-01-15/metadata/execution-environment" -LAMBDA_METADATA_TIMEOUT = 0.5 diff --git a/tests/integrations/aws_lambda/test_aws_lambda.py b/tests/integrations/aws_lambda/test_aws_lambda.py index ae6216d99a..b77cd961b6 100644 --- a/tests/integrations/aws_lambda/test_aws_lambda.py +++ b/tests/integrations/aws_lambda/test_aws_lambda.py @@ -17,7 +17,6 @@ IDENTIFIER, LATEST_FUNCTION_VERSION, ORIGIN, - SENTRY_KIND, ) from sentry_sdk.traces import SegmentNameSource @@ -966,7 +965,6 @@ def test_span_streaming_no_error(lambda_client, test_environment): assert _get_span_attr(attrs, SPANDATA.SENTRY_OP) == OP.FUNCTION_AWS assert _get_span_attr(attrs, SPANDATA.SENTRY_ORIGIN) == ORIGIN - assert _get_span_attr(attrs, SPANDATA.SENTRY_KIND) == SENTRY_KIND assert ( _get_span_attr(attrs, SPANDATA.SENTRY_SEGMENT_NAME_SOURCE) == SegmentNameSource.COMPONENT @@ -978,7 +976,6 @@ def test_span_streaming_no_error(lambda_client, test_environment): _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) == "arn:aws:lambda:us-east-1:012345678912:function:BasicOkSpanStreaming" ) - assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "BasicOkSpanStreaming" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs @@ -1033,7 +1030,6 @@ def test_span_streaming_error(lambda_client, test_environment): _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) == "arn:aws:lambda:us-east-1:012345678912:function:RaiseErrorSpanStreaming" ) - assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "RaiseErrorSpanStreaming" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs @@ -1087,7 +1083,6 @@ def test_span_streaming_trace_continuation(lambda_client, test_environment): ) assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM - assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "RaiseErrorSpanStreaming" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs @@ -1130,8 +1125,6 @@ def test_span_streaming_request_attributes(lambda_client, test_environment): assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "BasicOkSpanStreamingPii" assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM - assert _get_span_attr(attrs, SPANDATA.CLOUD_REGION) == "us-east-1" - assert _get_span_attr(attrs, SPANDATA.CLOUD_AVAILABILITY_ZONE) == "use1-az1" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs assert _get_span_attr(attrs, SPANDATA.AWS_LOG_GROUP_NAMES) == [ From 6843b76d2a026860b7f5d9faebf99d4ed013ac52 Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Fri, 9 Oct 2026 13:41:09 +0200 Subject: [PATCH 3/3] remove new attributes --- tests/integrations/aws_lambda/test_aws_lambda.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/integrations/aws_lambda/test_aws_lambda.py b/tests/integrations/aws_lambda/test_aws_lambda.py index b77cd961b6..088a59e96d 100644 --- a/tests/integrations/aws_lambda/test_aws_lambda.py +++ b/tests/integrations/aws_lambda/test_aws_lambda.py @@ -971,11 +971,6 @@ def test_span_streaming_no_error(lambda_client, test_environment): ) assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM - assert _get_span_attr(attrs, SPANDATA.CLOUD_ACCOUNT_ID) == "012345678912" - assert ( - _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) - == "arn:aws:lambda:us-east-1:012345678912:function:BasicOkSpanStreaming" - ) assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "BasicOkSpanStreaming" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs @@ -1026,10 +1021,6 @@ def test_span_streaming_error(lambda_client, test_environment): ) assert _get_span_attr(attrs, SPANDATA.CLOUD_PROVIDER) == CLOUD_PROVIDER assert _get_span_attr(attrs, SPANDATA.CLOUD_PLATFORM) == CLOUD_PLATFORM - assert ( - _get_span_attr(attrs, SPANDATA.CLOUD_RESOURCE_ID) - == "arn:aws:lambda:us-east-1:012345678912:function:RaiseErrorSpanStreaming" - ) assert _get_span_attr(attrs, SPANDATA.FAAS_NAME) == "RaiseErrorSpanStreaming" assert _get_span_attr(attrs, SPANDATA.FAAS_VERSION) == LATEST_FUNCTION_VERSION assert SPANDATA.FAAS_INVOCATION_ID in attrs