Skip to content

Commit 3327c04

Browse files
authored
feat(v9/aws): Detect SDK source for AWS Lambda layer (#17150)
backport of #17128
1 parent 473a4fe commit 3327c04

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

dev-packages/e2e-tests/test-applications/aws-lambda-layer-cjs/tests/basic.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ test('Lambda layer SDK bundle sends events', async ({ request }) => {
6969
op: 'test',
7070
}),
7171
);
72+
73+
// shows that the SDK source is correctly detected
74+
expect(transactionEvent.sdk?.packages).toContainEqual(
75+
expect.objectContaining({ name: 'aws-lambda-layer:@sentry/aws-serverless' }),
76+
);
7277
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,9 @@ test('AWS Serverless SDK sends events in ESM mode', async ({ request }) => {
8282
op: 'manual',
8383
}),
8484
);
85+
86+
// shows that the SDK source is correctly detected
87+
expect(transactionEvent.sdk?.packages).toContainEqual(
88+
expect.objectContaining({ name: 'npm:@sentry/aws-serverless' }),
89+
);
8590
});

dev-packages/rollup-utils/bundleHelpers.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function makeBaseBundleConfig(options) {
9898
plugins: [
9999
jsonPlugin,
100100
commonJSPlugin,
101+
makeSetSDKSourcePlugin('aws-lambda-layer'),
101102
// Temporary fix for the lambda layer SDK bundle.
102103
// This is necessary to apply to our lambda layer bundle because calling `new ImportInTheMiddle()` will throw an
103104
// that `ImportInTheMiddle` is not a constructor. Instead we modify the code to call `new ImportInTheMiddle.default()`

packages/aws-serverless/src/sdk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Integration, Options, Scope, Span } from '@sentry/core';
22
import {
33
applySdkMetadata,
44
debug,
5+
getSDKSource,
56
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
67
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
78
} from '@sentry/core';
@@ -81,7 +82,7 @@ export function init(options: NodeOptions = {}): NodeClient | undefined {
8182
...options,
8283
};
8384

84-
applySdkMetadata(opts, 'aws-serverless');
85+
applySdkMetadata(opts, 'aws-serverless', ['aws-serverless'], getSDKSource());
8586

8687
return initWithoutDefaultIntegrations(opts);
8788
}

packages/core/src/utils/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined;
1717

18-
export type SdkSource = 'npm' | 'cdn' | 'loader';
18+
export type SdkSource = 'npm' | 'cdn' | 'loader' | 'aws-lambda-layer';
1919

2020
/**
2121
* Figures out if we're building a browser bundle.

0 commit comments

Comments
 (0)