Skip to content

Commit f7d4930

Browse files
committed
remove everything related to AZ
1 parent de6721a commit f7d4930

7 files changed

Lines changed: 0 additions & 125 deletions

File tree

‎sentry_sdk/consts.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,6 @@ class SPANDATA:
453453
Example: "123456789012"
454454
"""
455455

456-
CLOUD_AVAILABILITY_ZONE = "cloud.availability_zone"
457-
"""
458-
Cloud regions often have multiple, isolated locations known as zones to increase availability
459-
Example: "us-east-1c"
460-
"""
461-
462456
CLOUD_PLATFORM = "cloud.platform"
463457
"""
464458
The cloud platform in use.

‎sentry_sdk/integrations/aws_lambda/_handler.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from sentry_sdk.data_collection import _apply_key_value_collection_filtering
1010
from sentry_sdk.integrations._wsgi_common import _filter_headers
1111
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
12-
from sentry_sdk.integrations.aws_lambda._metadata import _get_availability_zone
1312
from sentry_sdk.integrations.aws_lambda._request import (
1413
_get_user_from_event,
1514
_make_request_event_processor,
@@ -187,12 +186,6 @@ def sentry_handler(
187186
}
188187
)
189188

190-
if "AWS_LAMBDA_METADATA_API" in environ:
191-
with capture_internal_exceptions():
192-
availability_zone = _get_availability_zone()
193-
if availability_zone is not None:
194-
attributes[SPANDATA.CLOUD_AVAILABILITY_ZONE] = availability_zone
195-
196189
sentry_sdk.continue_trace(headers)
197190
Scope.set_custom_sampling_context(sampling_context)
198191
with sentry_sdk.start_span(

‎sentry_sdk/integrations/aws_lambda/_metadata.py‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎sentry_sdk/integrations/aws_lambda/consts.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
CLOUD_PROVIDER = "aws"
55
CLOUD_PLATFORM = "aws_lambda"
66
LATEST_FUNCTION_VERSION = "$LATEST"
7-
8-
LAMBDA_METADATA_PATH = "/2026-01-15/metadata/execution-environment"

‎tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollection/index.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
import sentry_sdk
44
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
55

6-
# otherwise SAM will call its built-in metadata endpoint/token.
7-
os.environ["AWS_LAMBDA_METADATA_API"] = os.environ[
8-
"SENTRY_TEST_AWS_LAMBDA_METADATA_API"
9-
]
10-
os.environ["AWS_LAMBDA_METADATA_TOKEN"] = os.environ[
11-
"SENTRY_TEST_AWS_LAMBDA_METADATA_TOKEN"
12-
]
136
# the alias is only in the name to get a qualified invoked ARN.
147
os.environ["AWS_LAMBDA_FUNCTION_NAME"] = os.environ["AWS_LAMBDA_FUNCTION_NAME"].split(
158
":"

‎tests/integrations/aws_lambda/test_aws_lambda.py‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -941,26 +941,6 @@ def test_url_query_params_with_data_collection(lambda_client, test_environment):
941941
_get_span_attr(attrs, SPANDATA.URL_QUERY)
942942
== "page=2&tracking=%5BFiltered%5D&token=%5BFiltered%5D"
943943
)
944-
assert _get_span_attr(attrs, SPANDATA.CLOUD_AVAILABILITY_ZONE) == "use1-az1"
945-
# The container may already be warm (and the metadata cached) from an earlier
946-
# test invoking the same function, so only assert that the second invocation
947-
# is served from the cache.
948-
metadata_requests = server.lambda_metadata_requests
949-
assert metadata_requests >= 1
950-
951-
server.clear_envelopes()
952-
lambda_client.invoke(
953-
FunctionName="BasicOkSpanStreamingDataCollection",
954-
Payload=json.dumps(payload),
955-
)
956-
segment_spans = [s for s in server.span_items if s["is_segment"]]
957-
958-
assert len(segment_spans) == 1
959-
assert (
960-
_get_span_attr(segment_spans[0]["attributes"], SPANDATA.CLOUD_AVAILABILITY_ZONE)
961-
== "use1-az1"
962-
)
963-
assert server.lambda_metadata_requests == metadata_requests
964944

965945

966946
def test_user_info_with_data_collection_user_info_off(lambda_client, test_environment):

‎tests/integrations/aws_lambda/utils.py‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
)
1818
from constructs import Construct
1919
from fastapi import FastAPI, Request
20-
from fastapi.responses import JSONResponse
2120

2221
from scripts.build_aws_lambda_layer import DIST_PATH, build_packaged_zip
23-
from sentry_sdk.integrations.aws_lambda.consts import LAMBDA_METADATA_PATH
2422

2523
LAMBDA_FUNCTION_DIR = "./tests/integrations/aws_lambda/lambda_functions/"
2624
LAMBDA_FUNCTION_WITH_EMBEDDED_SDK_DIR = (
2725
"./tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/"
2826
)
2927
LAMBDA_FUNCTION_TIMEOUT = 10
30-
LAMBDA_METADATA_TOKEN = "test-token"
3128
SAM_PORT = 3001
3229

3330
# functions invoked through a published version or an alias instead of `$LATEST`:
@@ -176,20 +173,6 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
176173
)
177174

178175
environment = {"SENTRY_DSN": dsn}
179-
if lambda_dir == "BasicOkSpanStreamingDataCollection":
180-
# AWS exposes these env. vars when the metadata endpoint
181-
# (`2026-01-15/metadata/execution-environment`) is available.
182-
# We set et them only on the function that exercises `cloud.availability_zone`.
183-
environment.update(
184-
{
185-
"SENTRY_TEST_AWS_LAMBDA_METADATA_API": (
186-
f"{get_host_ip()}:9999"
187-
),
188-
"SENTRY_TEST_AWS_LAMBDA_METADATA_TOKEN": (
189-
LAMBDA_METADATA_TOKEN
190-
),
191-
}
192-
)
193176
if lambda_dir in QUALIFIED_FUNCTIONS:
194177
qualifier, function_version = QUALIFIED_FUNCTIONS[lambda_dir]
195178
# SAM builds the invoked ARN from `AWS_LAMBDA_FUNCTION_NAME`,
@@ -258,7 +241,6 @@ class SentryServerForTesting:
258241
def __init__(self, host="0.0.0.0", port=9999, log_level="warning"):
259242
self.envelopes = []
260243
self.span_items = []
261-
self.lambda_metadata_requests = 0
262244
self.host = host
263245
self.port = port
264246
self.log_level = log_level
@@ -306,26 +288,6 @@ async def envelope(request: Request):
306288

307289
return {"status": "ok"}
308290

309-
@self.app.get(LAMBDA_METADATA_PATH)
310-
async def lambda_metadata(request: Request):
311-
"""
312-
Mirrors the Lambda execution-environment metadata endpoint
313-
(`2026-01-15/metadata/execution-environment`) used to collect
314-
`AvailabilityZoneID`, including its cache lifetime.
315-
https://docs.aws.amazon.com/lambda/latest/dg/configuration-metadata-endpoint.html
316-
"""
317-
self.lambda_metadata_requests += 1
318-
319-
if request.headers.get("Authorization") != (
320-
f"Bearer {LAMBDA_METADATA_TOKEN}"
321-
):
322-
return JSONResponse({"message": "Unauthorized"}, status_code=401)
323-
324-
return JSONResponse(
325-
{"AvailabilityZoneID": "use1-az1"},
326-
headers={"Cache-Control": "private, max-age=43200, immutable"},
327-
)
328-
329291
def run_server(self):
330292
uvicorn.run(self.app, host=self.host, port=self.port, log_level=self.log_level)
331293

0 commit comments

Comments
 (0)