@sentry/serverless
Advanced tools
Comparing version 7.73.0 to 7.74.0
@@ -27,8 +27,9 @@ var { | ||
function init(options = {}) { | ||
if (options.defaultIntegrations === undefined) { | ||
options.defaultIntegrations = defaultIntegrations; | ||
} | ||
const opts = { | ||
_metadata: {} , | ||
defaultIntegrations, | ||
...options, | ||
}; | ||
options._metadata = options._metadata || {}; | ||
options._metadata.sdk = { | ||
opts._metadata.sdk = opts._metadata.sdk || { | ||
name: 'sentry.javascript.serverless', | ||
@@ -45,3 +46,3 @@ integrations: ['AWSLambda'], | ||
Sentry.init(options); | ||
Sentry.init(opts); | ||
Sentry.addGlobalEventProcessor(utils.serverlessEventProcessor); | ||
@@ -136,7 +137,2 @@ } | ||
function enhanceScopeWithEnvironmentData(scope, context, startTime) { | ||
scope.setTransactionName(context.functionName); | ||
scope.setTag('server_name', process.env._AWS_XRAY_DAEMON_ADDRESS || process.env.SENTRY_NAME || os.hostname()); | ||
scope.setTag('url', `awslambda:///${context.functionName}`); | ||
scope.setContext('aws.lambda', { | ||
@@ -164,2 +160,14 @@ aws_request_id: context.awsRequestId, | ||
/** | ||
* Adds additional transaction-related information from the environment and AWS Context to the Sentry Scope. | ||
* | ||
* @param scope Scope that should be enhanced | ||
* @param context AWS Lambda context that will be used to extract some part of the data | ||
*/ | ||
function enhanceScopeWithTransactionData(scope, context) { | ||
scope.setTransactionName(context.functionName); | ||
scope.setTag('server_name', process.env._AWS_XRAY_DAEMON_ADDRESS || process.env.SENTRY_NAME || os.hostname()); | ||
scope.setTag('url', `awslambda:///${context.functionName}`); | ||
} | ||
/** | ||
* Wraps a lambda handler adding it error capture and tracing capabilities. | ||
@@ -182,2 +190,3 @@ * | ||
captureAllSettledReasons: false, | ||
startTrace: true, | ||
...wrapOptions, | ||
@@ -240,25 +249,28 @@ }; | ||
const eventWithHeaders = event ; | ||
let transaction; | ||
if (options.startTrace) { | ||
const eventWithHeaders = event ; | ||
const sentryTrace = | ||
eventWithHeaders.headers && utils$1.isString(eventWithHeaders.headers['sentry-trace']) | ||
? eventWithHeaders.headers['sentry-trace'] | ||
: undefined; | ||
const baggage = _optionalChain([eventWithHeaders, 'access', _ => _.headers, 'optionalAccess', _2 => _2.baggage]); | ||
const { traceparentData, dynamicSamplingContext, propagationContext } = utils$1.tracingContextFromHeaders( | ||
sentryTrace, | ||
baggage, | ||
); | ||
hub.getScope().setPropagationContext(propagationContext); | ||
const sentryTrace = | ||
eventWithHeaders.headers && utils$1.isString(eventWithHeaders.headers['sentry-trace']) | ||
? eventWithHeaders.headers['sentry-trace'] | ||
: undefined; | ||
const baggage = _optionalChain([eventWithHeaders, 'access', _ => _.headers, 'optionalAccess', _2 => _2.baggage]); | ||
const { traceparentData, dynamicSamplingContext, propagationContext } = utils$1.tracingContextFromHeaders( | ||
sentryTrace, | ||
baggage, | ||
); | ||
hub.getScope().setPropagationContext(propagationContext); | ||
const transaction = hub.startTransaction({ | ||
name: context.functionName, | ||
op: 'function.aws.lambda', | ||
origin: 'auto.function.serverless', | ||
...traceparentData, | ||
metadata: { | ||
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, | ||
source: 'component', | ||
}, | ||
}) ; | ||
transaction = hub.startTransaction({ | ||
name: context.functionName, | ||
op: 'function.aws.lambda', | ||
origin: 'auto.function.serverless', | ||
...traceparentData, | ||
metadata: { | ||
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, | ||
source: 'component', | ||
}, | ||
}); | ||
} | ||
@@ -269,4 +281,7 @@ const scope = hub.pushScope(); | ||
enhanceScopeWithEnvironmentData(scope, context, START_TIME); | ||
// We put the transaction on the scope so users can attach children to it | ||
scope.setSpan(transaction); | ||
if (options.startTrace) { | ||
enhanceScopeWithTransactionData(scope, context); | ||
// We put the transaction on the scope so users can attach children to it | ||
scope.setSpan(transaction); | ||
} | ||
rv = await asyncHandler(event, context); | ||
@@ -273,0 +288,0 @@ |
@@ -21,8 +21,9 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
function init(options = {}) { | ||
if (options.defaultIntegrations === undefined) { | ||
options.defaultIntegrations = defaultIntegrations; | ||
} | ||
const opts = { | ||
_metadata: {} , | ||
defaultIntegrations, | ||
...options, | ||
}; | ||
options._metadata = options._metadata || {}; | ||
options._metadata.sdk = { | ||
opts._metadata.sdk = opts._metadata.sdk || { | ||
name: 'sentry.javascript.serverless', | ||
@@ -39,3 +40,3 @@ integrations: ['GCPFunction'], | ||
Sentry.init(options); | ||
Sentry.init(opts); | ||
Sentry.addGlobalEventProcessor(utils.serverlessEventProcessor); | ||
@@ -42,0 +43,0 @@ } |
@@ -22,2 +22,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.addGlobalEventProcessor = Sentry.addGlobalEventProcessor; | ||
exports.addIntegration = Sentry.addIntegration; | ||
exports.addRequestDataToEvent = Sentry.addRequestDataToEvent; | ||
@@ -31,2 +32,3 @@ exports.autoDiscoverNodePerformanceMonitoringIntegrations = Sentry.autoDiscoverNodePerformanceMonitoringIntegrations; | ||
exports.configureScope = Sentry.configureScope; | ||
exports.continueTrace = Sentry.continueTrace; | ||
exports.createTransport = Sentry.createTransport; | ||
@@ -33,0 +35,0 @@ exports.deepReadDirSync = Sentry.deepReadDirSync; |
@@ -24,8 +24,9 @@ import { _optionalChain } from '@sentry/utils/esm/buildPolyfills'; | ||
function init(options = {}) { | ||
if (options.defaultIntegrations === undefined) { | ||
options.defaultIntegrations = defaultIntegrations; | ||
} | ||
const opts = { | ||
_metadata: {} , | ||
defaultIntegrations, | ||
...options, | ||
}; | ||
options._metadata = options._metadata || {}; | ||
options._metadata.sdk = { | ||
opts._metadata.sdk = opts._metadata.sdk || { | ||
name: 'sentry.javascript.serverless', | ||
@@ -42,3 +43,3 @@ integrations: ['AWSLambda'], | ||
Sentry.init(options); | ||
Sentry.init(opts); | ||
Sentry.addGlobalEventProcessor(serverlessEventProcessor); | ||
@@ -133,7 +134,2 @@ } | ||
function enhanceScopeWithEnvironmentData(scope, context, startTime) { | ||
scope.setTransactionName(context.functionName); | ||
scope.setTag('server_name', process.env._AWS_XRAY_DAEMON_ADDRESS || process.env.SENTRY_NAME || hostname()); | ||
scope.setTag('url', `awslambda:///${context.functionName}`); | ||
scope.setContext('aws.lambda', { | ||
@@ -161,2 +157,14 @@ aws_request_id: context.awsRequestId, | ||
/** | ||
* Adds additional transaction-related information from the environment and AWS Context to the Sentry Scope. | ||
* | ||
* @param scope Scope that should be enhanced | ||
* @param context AWS Lambda context that will be used to extract some part of the data | ||
*/ | ||
function enhanceScopeWithTransactionData(scope, context) { | ||
scope.setTransactionName(context.functionName); | ||
scope.setTag('server_name', process.env._AWS_XRAY_DAEMON_ADDRESS || process.env.SENTRY_NAME || hostname()); | ||
scope.setTag('url', `awslambda:///${context.functionName}`); | ||
} | ||
/** | ||
* Wraps a lambda handler adding it error capture and tracing capabilities. | ||
@@ -179,2 +187,3 @@ * | ||
captureAllSettledReasons: false, | ||
startTrace: true, | ||
...wrapOptions, | ||
@@ -237,25 +246,28 @@ }; | ||
const eventWithHeaders = event ; | ||
let transaction; | ||
if (options.startTrace) { | ||
const eventWithHeaders = event ; | ||
const sentryTrace = | ||
eventWithHeaders.headers && isString(eventWithHeaders.headers['sentry-trace']) | ||
? eventWithHeaders.headers['sentry-trace'] | ||
: undefined; | ||
const baggage = _optionalChain([eventWithHeaders, 'access', _ => _.headers, 'optionalAccess', _2 => _2.baggage]); | ||
const { traceparentData, dynamicSamplingContext, propagationContext } = tracingContextFromHeaders( | ||
sentryTrace, | ||
baggage, | ||
); | ||
hub.getScope().setPropagationContext(propagationContext); | ||
const sentryTrace = | ||
eventWithHeaders.headers && isString(eventWithHeaders.headers['sentry-trace']) | ||
? eventWithHeaders.headers['sentry-trace'] | ||
: undefined; | ||
const baggage = _optionalChain([eventWithHeaders, 'access', _ => _.headers, 'optionalAccess', _2 => _2.baggage]); | ||
const { traceparentData, dynamicSamplingContext, propagationContext } = tracingContextFromHeaders( | ||
sentryTrace, | ||
baggage, | ||
); | ||
hub.getScope().setPropagationContext(propagationContext); | ||
const transaction = hub.startTransaction({ | ||
name: context.functionName, | ||
op: 'function.aws.lambda', | ||
origin: 'auto.function.serverless', | ||
...traceparentData, | ||
metadata: { | ||
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, | ||
source: 'component', | ||
}, | ||
}) ; | ||
transaction = hub.startTransaction({ | ||
name: context.functionName, | ||
op: 'function.aws.lambda', | ||
origin: 'auto.function.serverless', | ||
...traceparentData, | ||
metadata: { | ||
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext, | ||
source: 'component', | ||
}, | ||
}); | ||
} | ||
@@ -266,4 +278,7 @@ const scope = hub.pushScope(); | ||
enhanceScopeWithEnvironmentData(scope, context, START_TIME); | ||
// We put the transaction on the scope so users can attach children to it | ||
scope.setSpan(transaction); | ||
if (options.startTrace) { | ||
enhanceScopeWithTransactionData(scope, context); | ||
// We put the transaction on the scope so users can attach children to it | ||
scope.setSpan(transaction); | ||
} | ||
rv = await asyncHandler(event, context); | ||
@@ -270,0 +285,0 @@ |
@@ -19,8 +19,9 @@ import * as Sentry from '@sentry/node'; | ||
function init(options = {}) { | ||
if (options.defaultIntegrations === undefined) { | ||
options.defaultIntegrations = defaultIntegrations; | ||
} | ||
const opts = { | ||
_metadata: {} , | ||
defaultIntegrations, | ||
...options, | ||
}; | ||
options._metadata = options._metadata || {}; | ||
options._metadata.sdk = { | ||
opts._metadata.sdk = opts._metadata.sdk || { | ||
name: 'sentry.javascript.serverless', | ||
@@ -37,3 +38,3 @@ integrations: ['GCPFunction'], | ||
Sentry.init(options); | ||
Sentry.init(opts); | ||
Sentry.addGlobalEventProcessor(serverlessEventProcessor); | ||
@@ -40,0 +41,0 @@ } |
@@ -6,3 +6,3 @@ import * as awslambda from './awslambda.js'; | ||
export { AWSServices } from './awsservices.js'; | ||
export { DEFAULT_USER_INCLUDES, Handlers, Hub, Integrations, NodeClient, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, addRequestDataToEvent, autoDiscoverNodePerformanceMonitoringIntegrations, captureCheckIn, captureEvent, captureException, captureMessage, close, configureScope, createTransport, deepReadDirSync, defaultIntegrations, defaultStackParser, extractRequestData, flush, getActiveSpan, getActiveTransaction, getCurrentHub, getHubFromCarrier, getSentryRelease, init, lastEventId, makeMain, makeNodeTransport, setContext, setExtra, setExtras, setMeasurement, setTag, setTags, setUser, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, startTransaction, withScope } from '@sentry/node'; | ||
export { DEFAULT_USER_INCLUDES, Handlers, Hub, Integrations, NodeClient, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, addIntegration, addRequestDataToEvent, autoDiscoverNodePerformanceMonitoringIntegrations, captureCheckIn, captureEvent, captureException, captureMessage, close, configureScope, continueTrace, createTransport, deepReadDirSync, defaultIntegrations, defaultStackParser, extractRequestData, flush, getActiveSpan, getActiveTransaction, getCurrentHub, getHubFromCarrier, getSentryRelease, init, lastEventId, makeMain, makeNodeTransport, setContext, setExtra, setExtras, setMeasurement, setTag, setTags, setUser, startActiveSpan, startInactiveSpan, startSpan, startSpanManual, startTransaction, withScope } from '@sentry/node'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@sentry/serverless", | ||
"version": "7.73.0", | ||
"version": "7.74.0", | ||
"description": "Official Sentry SDK for various serverless solutions", | ||
@@ -26,6 +26,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/core": "7.73.0", | ||
"@sentry/node": "7.73.0", | ||
"@sentry/types": "7.73.0", | ||
"@sentry/utils": "7.73.0", | ||
"@sentry/core": "7.74.0", | ||
"@sentry/node": "7.74.0", | ||
"@sentry/types": "7.74.0", | ||
"@sentry/utils": "7.74.0", | ||
"@types/aws-lambda": "^8.10.62", | ||
@@ -32,0 +32,0 @@ "@types/express": "^4.17.14", |
@@ -8,2 +8,5 @@ import * as Sentry from '@sentry/node'; | ||
flushTimeout: number; | ||
/** | ||
* @deprecated This option is unused since v6 and will be removed in v8. | ||
*/ | ||
rethrowAfterCapture?: boolean; | ||
@@ -19,2 +22,8 @@ callbackWaitsForEmptyEventLoop: boolean; | ||
captureAllSettledReasons: boolean; | ||
/** | ||
* Automatically trace all handler invocations. | ||
* You may want to disable this if you use express within Lambda (use tracingHandler instead). | ||
* @default true | ||
*/ | ||
startTrace: boolean; | ||
} | ||
@@ -21,0 +30,0 @@ export declare const defaultIntegrations: Integration[]; |
@@ -5,3 +5,3 @@ import * as AWSLambda from './awslambda'; | ||
export { AWSServices } from './awsservices'; | ||
export { Hub, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, autoDiscoverNodePerformanceMonitoringIntegrations, captureEvent, captureException, captureMessage, captureCheckIn, configureScope, createTransport, getActiveTransaction, getCurrentHub, getHubFromCarrier, makeMain, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, NodeClient, makeNodeTransport, close, defaultIntegrations, defaultStackParser, flush, getSentryRelease, init, lastEventId, DEFAULT_USER_INCLUDES, addRequestDataToEvent, extractRequestData, deepReadDirSync, Handlers, Integrations, setMeasurement, getActiveSpan, startSpan, startActiveSpan, startInactiveSpan, startSpanManual, } from '@sentry/node'; | ||
export { Hub, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, addIntegration, autoDiscoverNodePerformanceMonitoringIntegrations, captureEvent, captureException, captureMessage, captureCheckIn, configureScope, createTransport, getActiveTransaction, getCurrentHub, getHubFromCarrier, makeMain, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, NodeClient, makeNodeTransport, close, defaultIntegrations, defaultStackParser, flush, getSentryRelease, init, lastEventId, DEFAULT_USER_INCLUDES, addRequestDataToEvent, extractRequestData, deepReadDirSync, Handlers, Integrations, setMeasurement, getActiveSpan, startSpan, startActiveSpan, startInactiveSpan, startSpanManual, continueTrace, } from '@sentry/node'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,5 @@ import * as Sentry from '@sentry/node'; | ||
flushTimeout: number; | ||
/** | ||
* @deprecated This option is unused since v6 and will be removed in v8. | ||
*/ | ||
rethrowAfterCapture?: boolean; | ||
@@ -19,2 +22,8 @@ callbackWaitsForEmptyEventLoop: boolean; | ||
captureAllSettledReasons: boolean; | ||
/** | ||
* Automatically trace all handler invocations. | ||
* You may want to disable this if you use express within Lambda (use tracingHandler instead). | ||
* @default true | ||
*/ | ||
startTrace: boolean; | ||
} | ||
@@ -21,0 +30,0 @@ export declare const defaultIntegrations: Integration[]; |
@@ -5,3 +5,3 @@ import * as AWSLambda from './awslambda'; | ||
export { AWSServices } from './awsservices'; | ||
export { Hub, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, autoDiscoverNodePerformanceMonitoringIntegrations, captureEvent, captureException, captureMessage, captureCheckIn, configureScope, createTransport, getActiveTransaction, getCurrentHub, getHubFromCarrier, makeMain, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, NodeClient, makeNodeTransport, close, defaultIntegrations, defaultStackParser, flush, getSentryRelease, init, lastEventId, DEFAULT_USER_INCLUDES, addRequestDataToEvent, extractRequestData, deepReadDirSync, Handlers, Integrations, setMeasurement, getActiveSpan, startSpan, startActiveSpan, startInactiveSpan, startSpanManual, } from '@sentry/node'; | ||
export { Hub, SDK_VERSION, Scope, addBreadcrumb, addGlobalEventProcessor, addIntegration, autoDiscoverNodePerformanceMonitoringIntegrations, captureEvent, captureException, captureMessage, captureCheckIn, configureScope, createTransport, getActiveTransaction, getCurrentHub, getHubFromCarrier, makeMain, setContext, setExtra, setExtras, setTag, setTags, setUser, startTransaction, withScope, NodeClient, makeNodeTransport, close, defaultIntegrations, defaultStackParser, flush, getSentryRelease, init, lastEventId, DEFAULT_USER_INCLUDES, addRequestDataToEvent, extractRequestData, deepReadDirSync, Handlers, Integrations, setMeasurement, getActiveSpan, startSpan, startActiveSpan, startInactiveSpan, startSpanManual, continueTrace, } from '@sentry/node'; | ||
//# sourceMappingURL=index.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
350404
2391
+ Added@sentry-internal/tracing@7.74.0(transitive)
+ Added@sentry/core@7.74.0(transitive)
+ Added@sentry/node@7.74.0(transitive)
+ Added@sentry/types@7.74.0(transitive)
+ Added@sentry/utils@7.74.0(transitive)
- Removed@sentry-internal/tracing@7.73.0(transitive)
- Removed@sentry/core@7.73.0(transitive)
- Removed@sentry/node@7.73.0(transitive)
- Removed@sentry/types@7.73.0(transitive)
- Removed@sentry/utils@7.73.0(transitive)
Updated@sentry/core@7.74.0
Updated@sentry/node@7.74.0
Updated@sentry/types@7.74.0
Updated@sentry/utils@7.74.0