Repository navigation
feat(aws-lambda): Add Lambda runtime resource attributes - #7941
pabloDeputter wants to merge 6 commits into
Conversation
abe3bfa to
f1f8c35
Compare
Coverage Results 📊✅ 55850 passed | ❌ 2 failed | ⏭️ 2868 skipped | Total: 58720 | Pass Rate: 95.11% | Execution Time: 153m 34s 📊 Comparison with Base Branch
➕ New Tests (2)View new tests
❌ Failed Tests
|
| File | Patch coverage | Changed executable lines |
|---|---|---|
| sentry_sdk/integrations/aws_lambda/_handler.py | 0.00% | 0/27 covered; missed: 3, 8, 12, 40, 41, 116, 117, 118, 119, 120, 121, 127, 140, 156, 168, 169, 170, 171, 172, 173, 174, 176, 190, 191, 192, 193, 194 |
| sentry_sdk/integrations/aws_lambda/_metadata.py | 0.00% | 0/19 covered; missed: 1, 2, 3, 4, 6, 8, 15, 20, 23, 24, 26, 27, 30, 35, 36, 38, 43, 44, 45 |
| sentry_sdk/integrations/aws_lambda/_runtime.py | 0.00% | 0/3 covered; missed: 8, 25, 57 |
| sentry_sdk/integrations/aws_lambda/_request.py | 66.67% | 2/3 covered; missed: 120 |
| sentry_sdk/integrations/aws_lambda/consts.py | 100.00% | 1/1 covered |
Coverage diff
@@ Coverage Diff @@
## master #7941 +/-##
==========================================
- Coverage 90.23% 89.73% -0.50%
==========================================
Files 202 198 -4
Tracked lines 26660 21014 -5646
Branches 9926 7216 -2710
==========================================
- Hits 24055 18856 -5199
+ Misses 2605 2158 -447
+ Partials 1510 1234 -276Generated by Coverage Action
2060499 to
d5b8521
Compare
| arn_parts = invoked_function_arn.split(":") | ||
| resource_id = ":".join(arn_parts[:7]) | ||
| if function_version != LATEST_FUNCTION_VERSION: | ||
| resource_id = f"{resource_id}:{function_version}" |
There was a problem hiding this comment.
No test covers cloud.resource_id alias-to-version normalization
Please add coverage where function_version is not $LATEST (ideally with an aliased invoked ARN) so the cloud.resource_id rewrite path is actually verified.
Evidence
- Lines 191-194 build
resource_idfromarn_parts[:7], then appendfunction_versiononly when it is not$LATEST. - This is the PR's stated alias→version normalization for
cloud.resource_id. - Existing span-streaming tests only assert
$LATESTARNs (e.g.test_span_streaming_no_error); no test sets a published version or aliased invoked ARN.
Also found at 1 additional location
sentry_sdk/integrations/aws_lambda/_handler.py:22-22
Identified by Warden · code-review · 94Y-QB9
d5b8521 to
c191469
Compare
Description
Expand aws-lambda instrumentation with extra resource identity and runtime metadata following OTel (https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/).
Changes:
sentry.kind=server.cloud.account.id, extracted from the invoked function ARN.cloud.resource_idis now normalized from the invoked function ARN; keep the original value inaws.lambda.invoked_arnand replace an alias with the resolved published version when the function is not$LATEST.cloud.availability_zonefrom the metadata endpoint when available; cached using the sameCache-Control max-age; reduced during SnapStart initialization (https://docs.aws.amazon.com/lambda/latest/dg/configuration-metadata-endpoint.html).cloud.regionis now extracted fromAWS_REGIONenv. var;faas.namefromAWS_LAMBDA_FUNCTION_NAME;faas.versionfromAWS_LAMBDA_FUNCTION_VERSIONfollowing OTel (https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/#resource-detector).sentry_sdkon every test setup (for easier local testing so runs don’t reuse old behavior from earlier implementation).capture_internal_exceptions()around attribute extraction so that a single failure does not affect the other instrumentation.Tests:
test_span_streaming_url_query_params_with_data_collection(): verify that its availability-zone response is reused across warm invocations according toCache-Control.Issues
Resolves #7931