@sentry/node
Advanced tools
Comparing version 5.16.0-beta.3 to 5.16.0-beta.4
@@ -22,10 +22,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var reqUrl = req.url; | ||
var hub = core_1.getCurrentHub(); | ||
var transaction = hub.startSpan({ | ||
var traceId; | ||
var parentSpanId; | ||
// If there is a trace header set, we extract the data from it and set the span on the scope | ||
// to be the origin an created transaction set the parent_span_id / trace_id | ||
if (req.headers && utils_1.isString(req.headers['sentry-trace'])) { | ||
var span = apm_1.Span.fromTraceparent(req.headers['sentry-trace']); | ||
if (span) { | ||
traceId = span.traceId; | ||
parentSpanId = span.parentSpanId; | ||
} | ||
} | ||
var transaction = core_1.startTransaction({ | ||
name: reqMethod + " " + reqUrl, | ||
op: 'http.server', | ||
transaction: reqMethod + " " + reqUrl, | ||
parentSpanId: parentSpanId, | ||
traceId: traceId, | ||
}); | ||
hub.configureScope(function (scope) { | ||
// We put the transaction on the scope so users can attach children to it | ||
core_1.getCurrentHub().configureScope(function (scope) { | ||
scope.setSpan(transaction); | ||
}); | ||
// We also set __sentry_transaction on the response so people can grab the transaction there to add | ||
// spans to it later. | ||
res.__sentry_transaction = transaction; | ||
res.once('finish', function () { | ||
@@ -241,10 +257,6 @@ transaction.setHttpStatus(res.statusCode); | ||
function errorHandler(options) { | ||
return function sentryErrorMiddleware(error, req, res, next) { | ||
return function sentryErrorMiddleware(error, _req, res, next) { | ||
var shouldHandleError = (options && options.shouldHandleError) || defaultShouldHandleError; | ||
if (shouldHandleError(error)) { | ||
core_1.withScope(function (scope) { | ||
if (req.headers && utils_1.isString(req.headers['sentry-trace'])) { | ||
var span = apm_1.Span.fromTraceparent(req.headers['sentry-trace']); | ||
scope.setSpan(span); | ||
} | ||
core_1.withScope(function (_scope) { | ||
var eventId = core_1.captureException(error); | ||
@@ -251,0 +263,0 @@ res.sentry = eventId; |
@@ -58,4 +58,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var span; | ||
if (tracingEnabled) { | ||
span = core_1.getCurrentHub().startSpan({ | ||
var transaction; | ||
var scope = core_1.getCurrentHub().getScope(); | ||
if (scope) { | ||
transaction = scope.getSpan(); | ||
} | ||
if (tracingEnabled && transaction) { | ||
span = transaction.startChild({ | ||
description: (typeof options === 'string' || !options.method ? 'GET' : options.method) + " " + requestUrl, | ||
@@ -62,0 +67,0 @@ op: 'request', |
export declare const SDK_NAME = "sentry.javascript.node"; | ||
export declare const SDK_VERSION = "5.16.0-beta.3"; | ||
export declare const SDK_VERSION = "5.16.0-beta.4"; | ||
//# sourceMappingURL=version.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SDK_NAME = 'sentry.javascript.node'; | ||
exports.SDK_VERSION = '5.16.0-beta.3'; | ||
exports.SDK_VERSION = '5.16.0-beta.4'; | ||
//# sourceMappingURL=version.js.map |
import * as tslib_1 from "tslib"; | ||
import { Span } from '@sentry/apm'; | ||
import { captureException, getCurrentHub, withScope } from '@sentry/core'; | ||
import { captureException, getCurrentHub, startTransaction, withScope } from '@sentry/core'; | ||
import { forget, isPlainObject, isString, logger, normalize } from '@sentry/utils'; | ||
@@ -21,10 +21,26 @@ import * as cookie from 'cookie'; | ||
var reqUrl = req.url; | ||
var hub = getCurrentHub(); | ||
var transaction = hub.startSpan({ | ||
var traceId; | ||
var parentSpanId; | ||
// If there is a trace header set, we extract the data from it and set the span on the scope | ||
// to be the origin an created transaction set the parent_span_id / trace_id | ||
if (req.headers && isString(req.headers['sentry-trace'])) { | ||
var span = Span.fromTraceparent(req.headers['sentry-trace']); | ||
if (span) { | ||
traceId = span.traceId; | ||
parentSpanId = span.parentSpanId; | ||
} | ||
} | ||
var transaction = startTransaction({ | ||
name: reqMethod + " " + reqUrl, | ||
op: 'http.server', | ||
transaction: reqMethod + " " + reqUrl, | ||
parentSpanId: parentSpanId, | ||
traceId: traceId, | ||
}); | ||
hub.configureScope(function (scope) { | ||
// We put the transaction on the scope so users can attach children to it | ||
getCurrentHub().configureScope(function (scope) { | ||
scope.setSpan(transaction); | ||
}); | ||
// We also set __sentry_transaction on the response so people can grab the transaction there to add | ||
// spans to it later. | ||
res.__sentry_transaction = transaction; | ||
res.once('finish', function () { | ||
@@ -237,10 +253,6 @@ transaction.setHttpStatus(res.statusCode); | ||
export function errorHandler(options) { | ||
return function sentryErrorMiddleware(error, req, res, next) { | ||
return function sentryErrorMiddleware(error, _req, res, next) { | ||
var shouldHandleError = (options && options.shouldHandleError) || defaultShouldHandleError; | ||
if (shouldHandleError(error)) { | ||
withScope(function (scope) { | ||
if (req.headers && isString(req.headers['sentry-trace'])) { | ||
var span = Span.fromTraceparent(req.headers['sentry-trace']); | ||
scope.setSpan(span); | ||
} | ||
withScope(function (_scope) { | ||
var eventId = captureException(error); | ||
@@ -247,0 +259,0 @@ res.sentry = eventId; |
@@ -57,4 +57,9 @@ import { getCurrentHub } from '@sentry/core'; | ||
var span; | ||
if (tracingEnabled) { | ||
span = getCurrentHub().startSpan({ | ||
var transaction; | ||
var scope = getCurrentHub().getScope(); | ||
if (scope) { | ||
transaction = scope.getSpan(); | ||
} | ||
if (tracingEnabled && transaction) { | ||
span = transaction.startChild({ | ||
description: (typeof options === 'string' || !options.method ? 'GET' : options.method) + " " + requestUrl, | ||
@@ -61,0 +66,0 @@ op: 'request', |
export declare const SDK_NAME = "sentry.javascript.node"; | ||
export declare const SDK_VERSION = "5.16.0-beta.3"; | ||
export declare const SDK_VERSION = "5.16.0-beta.4"; | ||
//# sourceMappingURL=version.d.ts.map |
export var SDK_NAME = 'sentry.javascript.node'; | ||
export var SDK_VERSION = '5.16.0-beta.3'; | ||
export var SDK_VERSION = '5.16.0-beta.4'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@sentry/node", | ||
"version": "5.16.0-beta.3", | ||
"version": "5.16.0-beta.4", | ||
"description": "Offical Sentry SDK for Node.js", | ||
@@ -19,7 +19,7 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/apm": "5.16.0-beta.3", | ||
"@sentry/core": "5.16.0-beta.3", | ||
"@sentry/hub": "5.16.0-beta.3", | ||
"@sentry/types": "5.16.0-beta.3", | ||
"@sentry/utils": "5.16.0-beta.3", | ||
"@sentry/apm": "5.16.0-beta.4", | ||
"@sentry/core": "5.16.0-beta.4", | ||
"@sentry/hub": "5.16.0-beta.4", | ||
"@sentry/types": "5.16.0-beta.4", | ||
"@sentry/utils": "5.16.0-beta.4", | ||
"cookie": "^0.3.1", | ||
@@ -26,0 +26,0 @@ "https-proxy-agent": "^4.0.0", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
406981
4441
+ Added@sentry/apm@5.16.0-beta.4(transitive)
+ Added@sentry/browser@5.16.0-beta.4(transitive)
+ Added@sentry/core@5.16.0-beta.4(transitive)
+ Added@sentry/hub@5.16.0-beta.4(transitive)
+ Added@sentry/minimal@5.16.0-beta.4(transitive)
+ Added@sentry/types@5.16.0-beta.4(transitive)
+ Added@sentry/utils@5.16.0-beta.4(transitive)
- Removed@sentry/apm@5.16.0-beta.3(transitive)
- Removed@sentry/browser@5.16.0-beta.3(transitive)
- Removed@sentry/core@5.16.0-beta.3(transitive)
- Removed@sentry/hub@5.16.0-beta.3(transitive)
- Removed@sentry/minimal@5.16.0-beta.3(transitive)
- Removed@sentry/types@5.16.0-beta.3(transitive)
- Removed@sentry/utils@5.16.0-beta.3(transitive)
Updated@sentry/apm@5.16.0-beta.4
Updated@sentry/core@5.16.0-beta.4
Updated@sentry/hub@5.16.0-beta.4
Updated@sentry/types@5.16.0-beta.4
Updated@sentry/utils@5.16.0-beta.4