Skip to content

feat(aws-lambda): Add Lambda runtime resource attributes - #7941

Open
pabloDeputter wants to merge 9 commits into
major/3.0from
pablo/add-lambda-runtime-attributes
Open

pabloDeputter wants to merge 9 commits into
major/3.0from
pablo/add-lambda-runtime-attributes

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Description

Expand aws-lambda instrumentation with extra resource identity and runtime metadata following OTel (https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/).

Changes:

  • add sentry.kind=server.
  • add cloud.account.id, extracted from the invoked function ARN.
  • cloud.resource_id is now normalized from the invoked function ARN; keep the original value in aws.lambda.invoked_arn and replace an alias with the resolved published version when the function is not $LATEST.
  • cloud.region is now extracted from AWS_REGION env. var; faas.name from AWS_LAMBDA_FUNCTION_NAME; faas.version from AWS_LAMBDA_FUNCTION_VERSION following OTel (https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/#resource-detector).
  • refresh sentry_sdk on every test setup (for easier local testing so runs don’t reuse old behavior from earlier implementation).
  • add capture_internal_exceptions() around attribute extraction so that a single failure does not affect the other instrumentation.

Issues

Resolves #7931

@pabloDeputter
pabloDeputter added this pull request to stack #7940 October 9, 2026 12:55
@pabloDeputter
pabloDeputter force-pushed the pablo/add-lambda-runtime-attributes branch from abe3bfa to f1f8c35 Compare October 9, 2026 12:56
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 56199 passed | ⏭️ 2872 skipped | Total: 59071 | Pass Rate: 95.14% | Execution Time: 155m 37s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -81871
Passed Tests 📉 -77467
Failed Tests —
Skipped Tests 📉 -4404

All tests are passing successfully.

❌ Patch coverage is 25.00% (6 of 24 changed executable lines covered; target 80%).
Project statement coverage is 90.00% (down 0.25 percentage points from base (009f15f) to head (295d5c3)).

Changed files with executable lines (2)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_handler.py 19.05% 4/21 covered; missed: 116, 117, 118, 119, 120, 121, 127, 140, 156, 168, 169, 170, 171, 172, 173, 174, 176
sentry_sdk/integrations/aws_lambda/_request.py 66.67% 2/3 covered; missed: 120
Coverage diff
@@            Coverage Diff             @@
##        master     #7941       +/-##
==========================================
- Coverage    90.25%    90.00%    -0.25%
==========================================
  Files          202       197        -5
  Tracked lines     26660     20983     -5677
  Branches      9926      7208     -2718
==========================================
- Hits         24062     18885     -5177
+ Misses        2598      2098      -500
+ Partials      1510      1234      -276

Generated by Coverage Action

@pabloDeputter
pabloDeputter marked this pull request as ready for review October 9, 2026 13:12
@pabloDeputter
pabloDeputter requested a review from a team as a code owner October 9, 2026 13:12
Comment thread sentry_sdk/integrations/aws_lambda/_handler.py Outdated
Comment thread sentry_sdk/integrations/aws_lambda/_handler.py Outdated
Comment thread sentry_sdk/integrations/aws_lambda/consts.py Outdated
Comment thread sentry_sdk/integrations/aws_lambda/_metadata.py Outdated
Comment thread sentry_sdk/integrations/aws_lambda/_handler.py Outdated
@pabloDeputter
pabloDeputter force-pushed the pablo/add-lambda-runtime-attributes branch from 2060499 to d5b8521 Compare October 12, 2026 09:06
Comment thread sentry_sdk/integrations/aws_lambda/_handler.py Outdated
@pabloDeputter
pabloDeputter removed this pull request from stack #7940 October 15, 2026 18:35
@pabloDeputter
pabloDeputter added this pull request to stack #8043 October 15, 2026 19:20
@pabloDeputter
pabloDeputter force-pushed the pablo/add-lambda-runtime-attributes branch from d5b8521 to c191469 Compare October 15, 2026 19:20

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment 🙏🏻

return _lambda_metadata_cache[1]

# bearer token is required to prevent SSRF.
response = _lambda_metadata_http.request(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't make requests from the SDK. We need to only work with what we can intercept from the natural execution of a user's program without creating side effects like network or DB traffic that are not necessary for making the SDK work (e.g. sending events to Sentry).

Can we get this info from elsewhere? If not, let's not add it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok yeah makes sense, didn't think about this.

It's not really available anywhere else, so I'll remove it.

Base automatically changed from pablo/cleanup-lambda to major/3.0 October 16, 2026 12:56
@pabloDeputter
pabloDeputter force-pushed the pablo/add-lambda-runtime-attributes branch from f7d4930 to 295d5c3 Compare October 16, 2026 13:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(aws-lambda): Add AWS cloud attributes

2 participants