Skip to content

feat(attributes): Add FaaS/AWS conventions and deprecate Lambda-specific attributes#414

Merged
ericapisani merged 18 commits into
mainfrom
py-2307-add-conventions
Jun 10, 2026
Merged

feat(attributes): Add FaaS/AWS conventions and deprecate Lambda-specific attributes#414
ericapisani merged 18 commits into
mainfrom
py-2307-add-conventions

Conversation

@ericapisani

Copy link
Copy Markdown
Member

Add OTel-aligned attributes for FaaS and AWS Lambda context:

  • faas.invocation_id, faas.version, aws.lambda.invoked_arn
  • aws.log.group.names, aws.log.stream.names, cloud.resource_id

Deprecate corresponding AWS Lambda-specific attributes in favor of the OTel-aligned equivalents.

Refs PY-2307

…fic attributes

Add OTel-aligned attributes for FaaS and AWS Lambda context:
- faas.invocation_id, faas.version, aws.lambda.invoked_arn
- aws.log.group.names, aws.log.stream.names, cloud.resource_id

Deprecate corresponding AWS Lambda-specific attributes in favor of
the OTel-aligned equivalents.

Refs PY-2307
@linear-code

linear-code Bot commented Jun 3, 2026

Copy link
Copy Markdown

PY-2307

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (attributes) Add FaaS/AWS conventions and deprecate Lambda-specific attributes by ericapisani in #414
  • (description) Add span description conventions by mjq in #422

Internal Changes 🔧

  • (name) Disallow replaced attributes by mjq in #423

🤖 This preview updates automatically when you update the PR.

@ericapisani ericapisani requested a review from a team June 3, 2026 18:54
@ericapisani ericapisani marked this pull request as ready for review June 3, 2026 18:58
@ericapisani ericapisani requested review from a team, Lms24, cleptric, mjq and nsdeschenes as code owners June 3, 2026 18:58
Comment thread model/attributes/aws/aws__lambda__aws_request_id.json
Comment thread model/attributes/aws/aws__lambda__aws_request_id.json Outdated
Comment thread python/src/sentry_conventions/attributes.py

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@@ -0,0 +1,16 @@
{
"key": "cloud.resource_id",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

q: What's the difference between this attribute and aws.lambda.invoked_arn?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as a follow-up:

  • If there's no difference, which one should we prefer?
  • if there is a difference, can we document it in additional_context?

@ericapisani ericapisani Jun 10, 2026

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.

q: What's the difference between this attribute and aws.lambda.invoked_arn?

This attribute is more flexible in that it's meant to represent the identifier of any cloud resource regardless of the provider. It can hold the ARN from AWS (what could also be stored in aws.lambda.invoked_arn if it's referring to an AWS lambda resource), but also represent the full resource name from GCP or fully qualified resource ID on Azure.

From OTEL's docs:

Cloud provider-specific native identifier of the monitored cloud resource.

with these as example values:

arn:aws:lambda:REGION:ACCOUNT_ID:function:my-function; //run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID; /subscriptions/<SUBSCRIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>

as a follow-up:

If there's no difference, which one should we prefer?
if there is a difference, can we document it in additional_context?

On their "AWS lambda" page, they have a note which I'm interpreting as a recommendation to set the faas and cloud attributes alongside them:

CleanShot 2026-06-10 at 09 51 43@2x

Can definitely add a note to the additional_context though to provide some clarity here 👍🏻

Comment thread model/attributes/messaging/messaging__batch__message_count.json Outdated
@ericapisani ericapisani enabled auto-merge (squash) June 10, 2026 14:21
@ericapisani ericapisani disabled auto-merge June 10, 2026 14:23
Comment thread model/attributes/aws/aws__lambda__aws_request_id.json
@ericapisani ericapisani enabled auto-merge (squash) June 10, 2026 14:25
@ericapisani ericapisani disabled auto-merge June 10, 2026 14:28
Comment thread model/attributes/aws/aws__lambda__function_name.json
Comment thread model/attributes/faas/faas__invocation_id.json
…/faas pairs

Add bidirectional alias entries linking aws.lambda.function_name ↔ faas.name
and aws.lambda.function_version ↔ faas.version, matching the existing pattern
used by aws.lambda.aws_request_id ↔ faas.invocation_id.

Also align PII classification on aws.lambda.aws_request_id from 'maybe' to
'false' to match its alias faas.invocation_id, so aliased attributes are
treated consistently by scrubbing and product logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread javascript/sentry-conventions/src/attributes.ts
Comment thread javascript/sentry-conventions/src/attributes.ts
Comment thread python/src/sentry_conventions/attributes.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 11f8c5d. Configure here.

Comment thread model/attributes/aws/aws__lambda__aws_request_id.json
Comment thread model/attributes/aws/aws__lambda__function_version.json
… aws.lambda attrs

Four deprecated aws.lambda attributes had _status: null in their deprecation blocks,
which skips Relay's backfill migration for spans still using the old keys. Set them
all to 'backfill'.

Also align aws.lambda.function_version PII to 'false' to match its faas.version alias,
fixing a metadata mismatch that would cause inconsistent scrubbing depending on which
key is present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines +16741 to 16751
replacement: 'faas.invocation_id',
reason: 'This attribute is being deprecated in favor of faas.invocation_id',
},
aliases: [FAAS_INVOCATION_ID],
changelog: [
{ version: 'next', description: 'Deprecated aws.lambda.aws_request_id in favor of faas.invocation_id' },
{ version: '0.7.0', prs: [369], description: 'Added aws.lambda.aws_request_id attribute' },
],
},
[AWS_LAMBDA_EXECUTION_DURATION_IN_MILLIS]: {
brief: 'The execution duration of the Lambda function invocation in milliseconds',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The TypeScript DeprecationInfo interface is missing the status field, which is present in the Python equivalent and the source JSON models.
Severity: MEDIUM

Suggested Fix

Modify the generateMetadataTypes() function in generate_attributes.ts to include the status?: DeprecationStatus field in the DeprecationInfo interface definition. This will align the TypeScript type with the Python class and the underlying JSON data model.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: javascript/sentry-conventions/src/attributes.ts#L16732-L16751

Potential issue: The code generation script `generate_attributes.ts` fails to include
the `status` field when creating the TypeScript `DeprecationInfo` interface. The script
correctly reads the `_status` value from the JSON models and includes it in the Python
`DeprecationInfo` class, but omits it from the TypeScript definition. This prevents
TypeScript consumers from accessing the deprecation status (e.g., "backfill",
"normalize"), which is necessary for correctly handling attribute migration strategies.
This creates an inconsistency between the Python and TypeScript libraries.

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.

This is beyond the scope of this PR

@ericapisani ericapisani merged commit 3effd48 into main Jun 10, 2026
12 checks passed
@ericapisani ericapisani deleted the py-2307-add-conventions branch June 10, 2026 15:39
ericapisani added a commit to getsentry/sentry-python that referenced this pull request Jun 10, 2026
#6498)

When span streaming is enabled via the trace_lifecycle experiment, use
sentry_sdk.traces.start_span instead of start_transaction so the
function
span is emitted as a span envelope item with OTel-compatible attributes
(cloud.provider, cloud.platform, faas.*, aws.lambda.*).

Also adds CLOUD_PLATFORM.AWS_LAMBDA constant and updates the test server
helper to route span envelope items into a separate span_items list so
tests can assert on streamed spans independently of error envelopes.

Depends on getsentry/sentry-conventions#414
being
shipped first as it introduces a number of the conventions used here

Fixes PY-2307
Fixes #6005
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.

2 participants