Skip to content

Commit 62dc154

Browse files
msonnbclaude
andcommitted
feat(aws-serverless)!: Use function.aws span op for Lambda invocations
Use the registered provider-level op instead of `function.aws.lambda`. Adds `cloud.provider`, `cloud.platform`, and `faas.name`, which the platform-level detail now relies on but were not previously set. Ref: JS-3105 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8f91cc5 commit 62dc154

5 files changed

Lines changed: 45 additions & 16 deletions

File tree

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ Span operations (`sentry.op`) were aligned with the values defined in `@sentry/c
268268
- `@sentry/ember`: Route hook spans from `instrumentRoutePerformance` now use `function` instead of `ui.ember.route.<hook>`. The hook name is available on the new `code.function.name` and `ember.route.hook` attributes.
269269
- `@sentry/ember`: Runloop spans now use `ui.task` instead of `ui.ember.runloop.<queue>`. The queue is available on the new `ember.runloop.queue` attribute.
270270
- Browser SDKs: Paint spans (`first-paint`, `first-contentful-paint`) now use the registered `browser.paint` op instead of `paint`. This does not affect Session Replay, whose performance entries keep their own `paint` type.
271+
- `@sentry/aws-serverless`: Lambda invocation spans now use the registered `function.aws` op instead of `function.aws.lambda`. The new `cloud.provider=aws`, `cloud.platform=aws_lambda`, and `faas.name` attributes identify the platform and function.
271272

272273
If you reference these operations in dashboards, alerts, or `beforeSendSpan`, update them to the new values.
273274

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ test.describe('Lambda layer', () => {
3838
'sentry.sample_rate': 1,
3939
'sentry.source': 'custom',
4040
'sentry.origin': 'auto.otel.aws_lambda',
41-
'sentry.op': 'function.aws.lambda',
41+
'sentry.op': 'function.aws',
4242
'cloud.account.id': '012345678912',
43+
'cloud.platform': 'aws_lambda',
44+
'cloud.provider': 'aws',
4345
'faas.execution': expect.any(String),
4446
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerTracingCjs',
47+
'faas.name': 'LayerTracingCjs',
4548
'faas.coldstart': true,
4649
'sentry.kind': 'server',
4750
},
48-
op: 'function.aws.lambda',
51+
op: 'function.aws',
4952
origin: 'auto.otel.aws_lambda',
5053
span_id: expect.stringMatching(/[a-f0-9]{16}/),
5154
status: 'ok',
@@ -106,14 +109,17 @@ test.describe('Lambda layer', () => {
106109
'sentry.sample_rate': 1,
107110
'sentry.source': 'custom',
108111
'sentry.origin': 'auto.otel.aws_lambda',
109-
'sentry.op': 'function.aws.lambda',
112+
'sentry.op': 'function.aws',
110113
'cloud.account.id': '012345678912',
114+
'cloud.platform': 'aws_lambda',
115+
'cloud.provider': 'aws',
111116
'faas.execution': expect.any(String),
112117
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerTracingEsm',
118+
'faas.name': 'LayerTracingEsm',
113119
'faas.coldstart': true,
114120
'sentry.kind': 'server',
115121
},
116-
op: 'function.aws.lambda',
122+
op: 'function.aws',
117123
origin: 'auto.otel.aws_lambda',
118124
span_id: expect.stringMatching(/[a-f0-9]{16}/),
119125
status: 'ok',
@@ -229,14 +235,17 @@ test.describe('Lambda layer', () => {
229235
'sentry.sample_rate': 1,
230236
'sentry.source': 'custom',
231237
'sentry.origin': 'auto.otel.aws_lambda',
232-
'sentry.op': 'function.aws.lambda',
238+
'sentry.op': 'function.aws',
233239
'cloud.account.id': '012345678912',
240+
'cloud.platform': 'aws_lambda',
241+
'cloud.provider': 'aws',
234242
'faas.execution': expect.any(String),
235243
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerStreaming',
244+
'faas.name': 'LayerStreaming',
236245
'faas.coldstart': true,
237246
'sentry.kind': 'server',
238247
},
239-
op: 'function.aws.lambda',
248+
op: 'function.aws',
240249
origin: 'auto.otel.aws_lambda',
241250
span_id: expect.stringMatching(/[a-f0-9]{16}/),
242251
status: 'ok',
@@ -273,14 +282,15 @@ test.describe('Lambda layer', () => {
273282

274283
expect(transactionEvent.contexts?.trace).toEqual(
275284
expect.objectContaining({
276-
op: 'function.aws.lambda',
285+
op: 'function.aws',
277286
origin: 'auto.otel.aws_lambda',
278287
status: 'ok',
279288
data: expect.objectContaining({
280-
'sentry.op': 'function.aws.lambda',
289+
'sentry.op': 'function.aws',
281290
'sentry.origin': 'auto.otel.aws_lambda',
282291
'sentry.kind': 'server',
283292
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerCallback',
293+
'faas.name': 'LayerCallback',
284294
}),
285295
}),
286296
);

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ test.describe('NPM package', () => {
2424
'sentry.sample_rate': 1,
2525
'sentry.source': 'custom',
2626
'sentry.origin': 'auto.otel.aws_lambda',
27-
'sentry.op': 'function.aws.lambda',
27+
'sentry.op': 'function.aws',
2828
'cloud.account.id': '012345678912',
29+
'cloud.platform': 'aws_lambda',
30+
'cloud.provider': 'aws',
2931
'faas.execution': expect.any(String),
3032
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:NpmTracingCjs',
33+
'faas.name': 'NpmTracingCjs',
3134
'faas.coldstart': true,
3235
'sentry.kind': 'server',
3336
},
34-
op: 'function.aws.lambda',
37+
op: 'function.aws',
3538
origin: 'auto.otel.aws_lambda',
3639
span_id: expect.stringMatching(/[a-f0-9]{16}/),
3740
status: 'ok',
@@ -92,14 +95,17 @@ test.describe('NPM package', () => {
9295
'sentry.sample_rate': 1,
9396
'sentry.source': 'custom',
9497
'sentry.origin': 'auto.otel.aws_lambda',
95-
'sentry.op': 'function.aws.lambda',
98+
'sentry.op': 'function.aws',
9699
'cloud.account.id': '012345678912',
100+
'cloud.platform': 'aws_lambda',
101+
'cloud.provider': 'aws',
97102
'faas.execution': expect.any(String),
98103
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:NpmTracingEsm',
104+
'faas.name': 'NpmTracingEsm',
99105
'faas.coldstart': true,
100106
'sentry.kind': 'server',
101107
},
102-
op: 'function.aws.lambda',
108+
op: 'function.aws',
103109
origin: 'auto.otel.aws_lambda',
104110
span_id: expect.stringMatching(/[a-f0-9]{16}/),
105111
status: 'ok',

packages/aws-serverless/src/instrumentHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const lambdaMaxInitInMilliseconds = 10_000;
3232
type LambdaEvent = Parameters<typeof getAwsTraceData>[0];
3333

3434
/**
35-
* Wraps a Lambda handler with full auto-instrumentation: a `function.aws.lambda`
35+
* Wraps a Lambda handler with full auto-instrumentation: a `function.aws`
3636
* transaction that continues incoming traces, plus the scope, error-capture, timeout
3737
* warning, and flushing behavior of {@link wrapHandler}.
3838
*

packages/aws-serverless/src/requestSpanOptions.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
import { CLOUD_ACCOUNT_ID, FAAS_COLDSTART, SENTRY_KIND, URL_FULL } from '@sentry/conventions/attributes';
19+
import {
20+
CLOUD_ACCOUNT_ID,
21+
CLOUD_PLATFORM,
22+
CLOUD_PROVIDER,
23+
FAAS_COLDSTART,
24+
FAAS_NAME,
25+
SENTRY_KIND,
26+
URL_FULL,
27+
} from '@sentry/conventions/attributes';
28+
import { FAAS_FUNCTION_AWS_SPAN_OP } from '@sentry/conventions/op';
2029
import type { SpanAttributes, StartSpanOptions } from '@sentry/core';
2130
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2231
import type { Context } from 'aws-lambda';
@@ -30,20 +39,23 @@ interface ApiGatewayLikeEvent {
3039
}
3140

3241
/**
33-
* Builds the options for the `function.aws.lambda` transaction started for each invocation.
42+
* Builds the options for the `function.aws` transaction started for each invocation.
3443
*/
3544
export function getRequestSpanOptions(event: unknown, context: Context, requestIsColdStart: boolean): StartSpanOptions {
3645
// The span is started within the surrounding `continueTrace`, so it continues the incoming trace.
3746
return {
3847
name: context.functionName,
39-
op: 'function.aws.lambda',
48+
op: FAAS_FUNCTION_AWS_SPAN_OP,
4049
forceTransaction: true,
4150
attributes: {
4251
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.otel.aws_lambda',
4352
[SENTRY_KIND]: 'server',
4453
[ATTR_FAAS_EXECUTION]: context.awsRequestId,
4554
[ATTR_FAAS_ID]: context.invokedFunctionArn,
4655
[CLOUD_ACCOUNT_ID]: extractAccountId(context.invokedFunctionArn),
56+
[CLOUD_PROVIDER]: 'aws',
57+
[CLOUD_PLATFORM]: 'aws_lambda',
58+
[FAAS_NAME]: context.functionName,
4759
[FAAS_COLDSTART]: requestIsColdStart,
4860
...extractOtherEventFields(event),
4961
},

0 commit comments

Comments
 (0)