Skip to content

Commit 4e43ca6

Browse files
Lms24claude
andcommitted
feat(aws-serverless): Set component as the function.aws segment name source
`function.aws` spans left `sentry.segment.name.source` unset, so it defaulted to `custom` — which claims the user named the span. The name comes from the Lambda function, so `component` is what it is, and it matches the other FaaS spans. Applies in both trace lifecycles, so the static layer suite and the streamed npm suite are updated alongside it. Refs #23954 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7b635c0 commit 4e43ca6

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

MIGRATION.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,9 @@ their names are unchanged. The only new behaviour is the fallback: if neither th
998998
nor the `AWS_LAMBDA_FUNCTION_NAME` environment variable yields a function name, the span is named
999999
`Serverless function execution` instead of carrying an empty name. These spans continue to carry the
10001000
function name on `faas.name`, the request URL on `url.full`, and the invocation details on
1001-
`aws.lambda.*` and `aws.cloudwatch.logs.*`.
1001+
`aws.lambda.*` and `aws.cloudwatch.logs.*`. Their `sentry.segment.name.source` is now `component`
1002+
rather than `custom`, matching the other FaaS spans: the name comes from the function, not from the
1003+
user. This applies in both trace lifecycles.
10021004

10031005
#### Filtering and sampling
10041006

dev-packages/e2e-tests/test-applications/aws-serverless-layer/tests/layer.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe('Lambda layer', () => {
3636
expect(transactionEvent.contexts?.trace).toEqual({
3737
data: {
3838
'sentry.sample_rate': 1,
39-
'sentry.segment.name.source': 'custom',
39+
'sentry.segment.name.source': 'component',
4040
'sentry.origin': 'auto.aws_lambda',
4141
'sentry.op': 'function.aws',
4242
'cloud.account.id': '012345678912',
@@ -107,7 +107,7 @@ test.describe('Lambda layer', () => {
107107
expect(transactionEvent.contexts?.trace).toEqual({
108108
data: {
109109
'sentry.sample_rate': 1,
110-
'sentry.segment.name.source': 'custom',
110+
'sentry.segment.name.source': 'component',
111111
'sentry.origin': 'auto.aws_lambda',
112112
'sentry.op': 'function.aws',
113113
'cloud.account.id': '012345678912',
@@ -233,7 +233,7 @@ test.describe('Lambda layer', () => {
233233
expect(transactionEvent.contexts?.trace).toEqual({
234234
data: {
235235
'sentry.sample_rate': 1,
236-
'sentry.segment.name.source': 'custom',
236+
'sentry.segment.name.source': 'component',
237237
'sentry.origin': 'auto.aws_lambda',
238238
'sentry.op': 'function.aws',
239239
'cloud.account.id': '012345678912',

dev-packages/e2e-tests/test-applications/aws-serverless/tests/npm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function assertLambdaTrace(spans: SerializedStreamedSpan[], functionName: string
1818
'sentry.op': { value: 'function.aws', type: 'string' },
1919
'sentry.origin': { value: 'auto.aws_lambda', type: 'string' },
2020
'sentry.kind': { value: 'server', type: 'string' },
21-
'sentry.segment.name.source': { value: 'custom', type: 'string' },
21+
'sentry.segment.name.source': { value: 'component', type: 'string' },
2222
'cloud.account.id': { value: '012345678912', type: 'string' },
2323
'cloud.platform': { value: 'aws_lambda', type: 'string' },
2424
'cloud.provider': { value: 'aws', type: 'string' },

packages/aws-serverless/src/requestSpanOptions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ import {
2424
FAAS_NAME,
2525
SENTRY_KIND,
2626
SENTRY_OP,
27+
SENTRY_ORIGIN,
28+
SENTRY_SEGMENT_NAME_SOURCE,
2729
URL_FULL,
2830
} from '@sentry/conventions/attributes';
2931
import { FUNCTION_AWS } from '@sentry/conventions/op';
3032
import type { SpanAttributes, StartSpanOptions } from '@sentry/core';
3133
import {
3234
getClient,
3335
hasSpanStreamingEnabled,
34-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3536
SERVERLESS_FUNCTION_SPAN_NAME_FALLBACK,
3637
filterCollectedUrl,
3738
} from '@sentry/core';
@@ -61,7 +62,8 @@ export function getRequestSpanOptions(event: unknown, context: Context, requestI
6162
: context.functionName,
6263
attributes: {
6364
[SENTRY_OP]: FUNCTION_AWS,
64-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.aws_lambda',
65+
[SENTRY_ORIGIN]: 'auto.aws_lambda',
66+
[SENTRY_SEGMENT_NAME_SOURCE]: 'component',
6567
[SENTRY_KIND]: 'server',
6668
[ATTR_FAAS_EXECUTION]: context.awsRequestId,
6769
[ATTR_FAAS_ID]: context.invokedFunctionArn,

0 commit comments

Comments
 (0)