@sentry/apm
Advanced tools
Comparing version 5.18.1 to 5.19.0
@@ -5,2 +5,3 @@ import { Hub } from '@sentry/hub'; | ||
import { Transaction } from '../transaction'; | ||
import { Location } from './types'; | ||
/** | ||
@@ -150,2 +151,10 @@ * Options for Tracing integration | ||
/** | ||
* Returns a new Transaction either continued from sentry-trace meta or a new one | ||
*/ | ||
private static _getNewTransaction; | ||
/** | ||
* Returns the value of a meta tag | ||
*/ | ||
private static _getMeta; | ||
/** | ||
* Pings the heartbeat | ||
@@ -152,0 +161,0 @@ */ |
@@ -5,2 +5,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("@sentry/utils"); | ||
var span_1 = require("../span"); | ||
var spanstatus_1 = require("../spanstatus"); | ||
@@ -101,2 +102,30 @@ var global = utils_1.getGlobalObject(); | ||
/** | ||
* Returns a new Transaction either continued from sentry-trace meta or a new one | ||
*/ | ||
Tracing._getNewTransaction = function (hub, transactionContext) { | ||
var traceId; | ||
var parentSpanId; | ||
var sampled; | ||
var header = Tracing._getMeta('sentry-trace'); | ||
if (header) { | ||
var span = span_1.Span.fromTraceparent(header); | ||
if (span) { | ||
traceId = span.traceId; | ||
parentSpanId = span.parentSpanId; | ||
sampled = span.sampled; | ||
Tracing._log("[Tracing] found 'sentry-meta' '<meta />' continuing trace with: trace_id: " + traceId + " span_id: " + parentSpanId); | ||
} | ||
} | ||
return hub.startTransaction(tslib_1.__assign({ parentSpanId: parentSpanId, | ||
sampled: sampled, | ||
traceId: traceId, trimEnd: true }, transactionContext)); | ||
}; | ||
/** | ||
* Returns the value of a meta tag | ||
*/ | ||
Tracing._getMeta = function (metaName) { | ||
var el = document.querySelector("meta[name=" + metaName + "]"); | ||
return el ? el.getAttribute('content') : null; | ||
}; | ||
/** | ||
* Pings the heartbeat | ||
@@ -261,3 +290,3 @@ */ | ||
} | ||
Tracing._activeTransaction = hub.startTransaction(tslib_1.__assign({ trimEnd: true }, transactionContext)); | ||
Tracing._activeTransaction = Tracing._getNewTransaction(hub, transactionContext); | ||
// We set the transaction here on the scope so error events pick up the trace context and attach it to the error | ||
@@ -318,3 +347,3 @@ hub.configureScope(function (scope) { return scope.setSpan(Tracing._activeTransaction); }); | ||
Tracing._addPerformanceEntries = function (transactionSpan) { | ||
if (!global.performance) { | ||
if (!global.performance || !global.performance.getEntries) { | ||
// Gatekeeper if performance API not available | ||
@@ -598,12 +627,12 @@ return; | ||
Tracing._log("[Tracing] popActivity " + activity.name + "#" + id); | ||
var span_1 = activity.span; | ||
if (span_1) { | ||
var span_2 = activity.span; | ||
if (span_2) { | ||
if (spanData) { | ||
Object.keys(spanData).forEach(function (key) { | ||
span_1.setData(key, spanData[key]); | ||
span_2.setData(key, spanData[key]); | ||
if (key === 'status_code') { | ||
span_1.setHttpStatus(spanData[key]); | ||
span_2.setHttpStatus(spanData[key]); | ||
} | ||
if (key === 'status') { | ||
span_1.setStatus(spanData[key]); | ||
span_2.setStatus(spanData[key]); | ||
} | ||
@@ -613,5 +642,5 @@ }); | ||
if (Tracing.options && Tracing.options.debug && Tracing.options.debug.spanDebugTimingInfo) { | ||
Tracing._addSpanDebugInfo(span_1); | ||
Tracing._addSpanDebugInfo(span_2); | ||
} | ||
span_1.finish(); | ||
span_2.finish(); | ||
} | ||
@@ -731,14 +760,23 @@ // tslint:disable-next-line: no-dynamic-delete | ||
if (span) { | ||
var request = (handlerData.args[0] = handlerData.args[0]); | ||
var options = (handlerData.args[1] = handlerData.args[1] || {}); | ||
if (options.headers) { | ||
if (Array.isArray(options.headers)) { | ||
options.headers = tslib_1.__spread(options.headers, [{ 'sentry-trace': span.toTraceparent() }]); | ||
var headers = options.headers; | ||
if (utils_1.isInstanceOf(request, Request)) { | ||
headers = request.headers; | ||
} | ||
if (headers) { | ||
if (typeof headers.append === 'function') { | ||
headers.append('sentry-trace', span.toTraceparent()); | ||
} | ||
else if (Array.isArray(headers)) { | ||
headers = tslib_1.__spread(headers, [['sentry-trace', span.toTraceparent()]]); | ||
} | ||
else { | ||
options.headers = tslib_1.__assign({}, options.headers, { 'sentry-trace': span.toTraceparent() }); | ||
headers = tslib_1.__assign({}, headers, { 'sentry-trace': span.toTraceparent() }); | ||
} | ||
} | ||
else { | ||
options.headers = { 'sentry-trace': span.toTraceparent() }; | ||
headers = { 'sentry-trace': span.toTraceparent() }; | ||
} | ||
options.headers = headers; | ||
} | ||
@@ -745,0 +783,0 @@ } |
@@ -5,2 +5,3 @@ import { Hub } from '@sentry/hub'; | ||
import { Transaction } from '../transaction'; | ||
import { Location } from './types'; | ||
/** | ||
@@ -150,2 +151,10 @@ * Options for Tracing integration | ||
/** | ||
* Returns a new Transaction either continued from sentry-trace meta or a new one | ||
*/ | ||
private static _getNewTransaction; | ||
/** | ||
* Returns the value of a meta tag | ||
*/ | ||
private static _getMeta; | ||
/** | ||
* Pings the heartbeat | ||
@@ -152,0 +161,0 @@ */ |
import * as tslib_1 from "tslib"; | ||
import { Severity } from '@sentry/types'; | ||
import { addInstrumentationHandler, getGlobalObject, isMatchingPattern, logger, safeJoin, supportsNativeFetch, timestampWithMs, } from '@sentry/utils'; | ||
import { addInstrumentationHandler, getGlobalObject, isInstanceOf, isMatchingPattern, logger, safeJoin, supportsNativeFetch, timestampWithMs, } from '@sentry/utils'; | ||
import { Span as SpanClass } from '../span'; | ||
import { SpanStatus } from '../spanstatus'; | ||
@@ -99,2 +100,30 @@ var global = getGlobalObject(); | ||
/** | ||
* Returns a new Transaction either continued from sentry-trace meta or a new one | ||
*/ | ||
Tracing._getNewTransaction = function (hub, transactionContext) { | ||
var traceId; | ||
var parentSpanId; | ||
var sampled; | ||
var header = Tracing._getMeta('sentry-trace'); | ||
if (header) { | ||
var span = SpanClass.fromTraceparent(header); | ||
if (span) { | ||
traceId = span.traceId; | ||
parentSpanId = span.parentSpanId; | ||
sampled = span.sampled; | ||
Tracing._log("[Tracing] found 'sentry-meta' '<meta />' continuing trace with: trace_id: " + traceId + " span_id: " + parentSpanId); | ||
} | ||
} | ||
return hub.startTransaction(tslib_1.__assign({ parentSpanId: parentSpanId, | ||
sampled: sampled, | ||
traceId: traceId, trimEnd: true }, transactionContext)); | ||
}; | ||
/** | ||
* Returns the value of a meta tag | ||
*/ | ||
Tracing._getMeta = function (metaName) { | ||
var el = document.querySelector("meta[name=" + metaName + "]"); | ||
return el ? el.getAttribute('content') : null; | ||
}; | ||
/** | ||
* Pings the heartbeat | ||
@@ -259,3 +288,3 @@ */ | ||
} | ||
Tracing._activeTransaction = hub.startTransaction(tslib_1.__assign({ trimEnd: true }, transactionContext)); | ||
Tracing._activeTransaction = Tracing._getNewTransaction(hub, transactionContext); | ||
// We set the transaction here on the scope so error events pick up the trace context and attach it to the error | ||
@@ -316,3 +345,3 @@ hub.configureScope(function (scope) { return scope.setSpan(Tracing._activeTransaction); }); | ||
Tracing._addPerformanceEntries = function (transactionSpan) { | ||
if (!global.performance) { | ||
if (!global.performance || !global.performance.getEntries) { | ||
// Gatekeeper if performance API not available | ||
@@ -727,14 +756,23 @@ return; | ||
if (span) { | ||
var request = (handlerData.args[0] = handlerData.args[0]); | ||
var options = (handlerData.args[1] = handlerData.args[1] || {}); | ||
if (options.headers) { | ||
if (Array.isArray(options.headers)) { | ||
options.headers = tslib_1.__spread(options.headers, [{ 'sentry-trace': span.toTraceparent() }]); | ||
var headers = options.headers; | ||
if (isInstanceOf(request, Request)) { | ||
headers = request.headers; | ||
} | ||
if (headers) { | ||
if (typeof headers.append === 'function') { | ||
headers.append('sentry-trace', span.toTraceparent()); | ||
} | ||
else if (Array.isArray(headers)) { | ||
headers = tslib_1.__spread(headers, [['sentry-trace', span.toTraceparent()]]); | ||
} | ||
else { | ||
options.headers = tslib_1.__assign({}, options.headers, { 'sentry-trace': span.toTraceparent() }); | ||
headers = tslib_1.__assign({}, headers, { 'sentry-trace': span.toTraceparent() }); | ||
} | ||
} | ||
else { | ||
options.headers = { 'sentry-trace': span.toTraceparent() }; | ||
headers = { 'sentry-trace': span.toTraceparent() }; | ||
} | ||
options.headers = headers; | ||
} | ||
@@ -741,0 +779,0 @@ } |
{ | ||
"name": "@sentry/apm", | ||
"version": "5.18.1", | ||
"version": "5.19.0", | ||
"description": "Extensions for APM", | ||
@@ -19,7 +19,7 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/browser": "5.18.1", | ||
"@sentry/hub": "5.18.1", | ||
"@sentry/minimal": "5.18.1", | ||
"@sentry/types": "5.18.1", | ||
"@sentry/utils": "5.18.1", | ||
"@sentry/browser": "5.19.0", | ||
"@sentry/hub": "5.19.0", | ||
"@sentry/minimal": "5.19.0", | ||
"@sentry/types": "5.19.0", | ||
"@sentry/utils": "5.19.0", | ||
"tslib": "^1.9.3" | ||
@@ -26,0 +26,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
385413
82
4255
+ Added@sentry/browser@5.19.0(transitive)
+ Added@sentry/core@5.19.0(transitive)
+ Added@sentry/hub@5.19.0(transitive)
+ Added@sentry/minimal@5.19.0(transitive)
+ Added@sentry/types@5.19.0(transitive)
+ Added@sentry/utils@5.19.0(transitive)
- Removed@sentry/browser@5.18.1(transitive)
- Removed@sentry/core@5.18.1(transitive)
- Removed@sentry/hub@5.18.1(transitive)
- Removed@sentry/minimal@5.18.1(transitive)
- Removed@sentry/types@5.18.1(transitive)
- Removed@sentry/utils@5.18.1(transitive)
Updated@sentry/browser@5.19.0
Updated@sentry/hub@5.19.0
Updated@sentry/minimal@5.19.0
Updated@sentry/types@5.19.0
Updated@sentry/utils@5.19.0