Skip to content

feat(v9/aws): Detect SDK source for AWS Lambda layer #17150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
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 @@ -69,4 +69,9 @@ test('Lambda layer SDK bundle sends events', async ({ request }) => {
op: 'test',
}),
);

// shows that the SDK source is correctly detected
expect(transactionEvent.sdk?.packages).toContainEqual(
expect.objectContaining({ name: 'aws-lambda-layer:@sentry/aws-serverless' }),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,9 @@ test('AWS Serverless SDK sends events in ESM mode', async ({ request }) => {
op: 'manual',
}),
);

// shows that the SDK source is correctly detected
expect(transactionEvent.sdk?.packages).toContainEqual(
expect.objectContaining({ name: 'npm:@sentry/aws-serverless' }),
);
});
1 change: 1 addition & 0 deletions dev-packages/rollup-utils/bundleHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function makeBaseBundleConfig(options) {
plugins: [
jsonPlugin,
commonJSPlugin,
makeSetSDKSourcePlugin('aws-lambda-layer'),
// Temporary fix for the lambda layer SDK bundle.
// This is necessary to apply to our lambda layer bundle because calling `new ImportInTheMiddle()` will throw an
// that `ImportInTheMiddle` is not a constructor. Instead we modify the code to call `new ImportInTheMiddle.default()`
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-serverless/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Integration, Options, Scope, Span } from '@sentry/core';
import {
applySdkMetadata,
debug,
getSDKSource,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
} from '@sentry/core';
Expand Down Expand Up @@ -81,7 +82,7 @@ export function init(options: NodeOptions = {}): NodeClient | undefined {
...options,
};

applySdkMetadata(opts, 'aws-serverless');
applySdkMetadata(opts, 'aws-serverless', ['aws-serverless'], getSDKSource());

return initWithoutDefaultIntegrations(opts);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined;

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

/**
* Figures out if we're building a browser bundle.
Expand Down
Loading