-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set global event processor and pass scope data for transactions in se…
…rverless (#2975)
- Loading branch information
1 parent
83c8e45
commit 2ed3b46
Showing
10 changed files
with
371 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import * as Sentry from '@sentry/node'; | ||
|
||
import { serverlessEventProcessor } from '../utils'; | ||
|
||
export * from './http'; | ||
export * from './events'; | ||
export * from './cloud_events'; | ||
export { init } from '@sentry/node'; | ||
|
||
/** | ||
* @see {@link Sentry.init} | ||
*/ | ||
export function init(options: Sentry.NodeOptions = {}): void { | ||
Sentry.init(options); | ||
Sentry.addGlobalEventProcessor(serverlessEventProcessor('GCPFunction')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Event, SDK_VERSION } from '@sentry/node'; | ||
import { addExceptionMechanism } from '@sentry/utils'; | ||
|
||
/** | ||
* Event processor that will override SDK details to point to the serverless SDK instead of Node, | ||
* as well as set correct mechanism type, which should be set to `handled: false`. | ||
* We do it like this, so that we don't introduce any side-effects in this module, which makes it tree-shakeable. | ||
* @param event Event | ||
* @param integration Name of the serverless integration ('AWSLambda', 'GCPFunction', etc) | ||
*/ | ||
export function serverlessEventProcessor(integration: string): (event: Event) => Event { | ||
return event => { | ||
event.sdk = { | ||
...event.sdk, | ||
name: 'sentry.javascript.serverless', | ||
integrations: [...((event.sdk && event.sdk.integrations) || []), integration], | ||
packages: [ | ||
...((event.sdk && event.sdk.packages) || []), | ||
{ | ||
name: 'npm:@sentry/serverless', | ||
version: SDK_VERSION, | ||
}, | ||
], | ||
version: SDK_VERSION, | ||
}; | ||
|
||
addExceptionMechanism(event, { | ||
handled: false, | ||
}); | ||
|
||
return event; | ||
}; | ||
} |
Oops, something went wrong.