Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ test.describe('Lambda layer', () => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'cloud.account.id': '012345678912',
'cloud.platform': 'aws_lambda',
'cloud.provider': 'aws',
'faas.execution': expect.any(String),
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerTracingCjs',
'faas.name': 'LayerTracingCjs',
'faas.coldstart': true,
'sentry.kind': 'server',
},
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down Expand Up @@ -106,14 +109,17 @@ test.describe('Lambda layer', () => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'cloud.account.id': '012345678912',
'cloud.platform': 'aws_lambda',
'cloud.provider': 'aws',
'faas.execution': expect.any(String),
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerTracingEsm',
'faas.name': 'LayerTracingEsm',
'faas.coldstart': true,
'sentry.kind': 'server',
},
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down Expand Up @@ -229,14 +235,17 @@ test.describe('Lambda layer', () => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'cloud.account.id': '012345678912',
'cloud.platform': 'aws_lambda',
'cloud.provider': 'aws',
'faas.execution': expect.any(String),
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerStreaming',
'faas.name': 'LayerStreaming',
'faas.coldstart': true,
'sentry.kind': 'server',
},
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down Expand Up @@ -273,14 +282,15 @@ test.describe('Lambda layer', () => {

expect(transactionEvent.contexts?.trace).toEqual(
expect.objectContaining({
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
status: 'ok',
data: expect.objectContaining({
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.kind': 'server',
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:LayerCallback',
'faas.name': 'LayerCallback',
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ test.describe('NPM package', () => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'cloud.account.id': '012345678912',
'cloud.platform': 'aws_lambda',
'cloud.provider': 'aws',
'faas.execution': expect.any(String),
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:NpmTracingCjs',
'faas.name': 'NpmTracingCjs',
'faas.coldstart': true,
'sentry.kind': 'server',
},
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down Expand Up @@ -92,14 +95,17 @@ test.describe('NPM package', () => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'sentry.origin': 'auto.otel.aws_lambda',
'sentry.op': 'function.aws.lambda',
'sentry.op': 'function.aws',
'cloud.account.id': '012345678912',
'cloud.platform': 'aws_lambda',
'cloud.provider': 'aws',
'faas.execution': expect.any(String),
'faas.id': 'arn:aws:lambda:us-east-1:012345678912:function:NpmTracingEsm',
'faas.name': 'NpmTracingEsm',
'faas.coldstart': true,
'sentry.kind': 'server',
},
op: 'function.aws.lambda',
op: 'function.aws',
origin: 'auto.otel.aws_lambda',
span_id: expect.stringMatching(/[a-f0-9]{16}/),
status: 'ok',
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-serverless/src/instrumentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const lambdaMaxInitInMilliseconds = 10_000;
type LambdaEvent = Parameters<typeof getAwsTraceData>[0];

/**
* Wraps a Lambda handler with full auto-instrumentation: a `function.aws.lambda`
* Wraps a Lambda handler with full auto-instrumentation: a `function.aws`
* transaction that continues incoming traces, plus the scope, error-capture, timeout
* warning, and flushing behavior of {@link wrapHandler}.
*
Expand Down
19 changes: 16 additions & 3 deletions packages/aws-serverless/src/requestSpanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CLOUD_ACCOUNT_ID, FAAS_COLDSTART, SENTRY_KIND, URL_FULL } from '@sentry/conventions/attributes';
import {
CLOUD_ACCOUNT_ID,
CLOUD_PLATFORM,
CLOUD_PROVIDER,
FAAS_COLDSTART,
FAAS_NAME,
SENTRY_KIND,
SENTRY_OP,
URL_FULL,
} from '@sentry/conventions/attributes';
import { FAAS_FUNCTION_AWS_SPAN_OP } from '@sentry/conventions/op';
import type { SpanAttributes, StartSpanOptions } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import type { Context } from 'aws-lambda';
Expand All @@ -30,20 +40,23 @@ interface ApiGatewayLikeEvent {
}

/**
* Builds the options for the `function.aws.lambda` transaction started for each invocation.
* Builds the options for the `function.aws` transaction started for each invocation.
*/
export function getRequestSpanOptions(event: unknown, context: Context, requestIsColdStart: boolean): StartSpanOptions {
// The span is started within the surrounding `continueTrace`, so it continues the incoming trace.
return {
name: context.functionName,
op: 'function.aws.lambda',
forceTransaction: true,
attributes: {
[SENTRY_OP]: FAAS_FUNCTION_AWS_SPAN_OP,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.otel.aws_lambda',
[SENTRY_KIND]: 'server',
[ATTR_FAAS_EXECUTION]: context.awsRequestId,
[ATTR_FAAS_ID]: context.invokedFunctionArn,
[CLOUD_ACCOUNT_ID]: extractAccountId(context.invokedFunctionArn),
[CLOUD_PROVIDER]: 'aws',
[CLOUD_PLATFORM]: 'aws_lambda',
[FAAS_NAME]: context.functionName,
[FAAS_COLDSTART]: requestIsColdStart,
...extractOtherEventFields(event),
},
Expand Down
Loading