From cd2ae458d37cfd71eaf005047c33269a6405c929 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 16 Jul 2019 12:29:00 +0200 Subject: [PATCH 01/12] feat: Trace outgoing XHR, Create transaction event --- src/sentry/static/sentry/app/api.jsx | 12 +++++++- src/sentry/static/sentry/app/bootstrap.jsx | 35 +++++++++++++++++++++- src/sentry/static/sentry/app/views/app.jsx | 12 +++++--- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/sentry/static/sentry/app/api.jsx b/src/sentry/static/sentry/app/api.jsx index dd4ae16c62bb74..ecec8e59ae626f 100644 --- a/src/sentry/static/sentry/app/api.jsx +++ b/src/sentry/static/sentry/app/api.jsx @@ -174,11 +174,18 @@ export class Client { }); throw err; } + const method = options.method || (options.data ? 'POST' : 'GET'); let data = options.data; const id = uniqueId(); metric.mark(`api-request-start-${id}`); + const requestSpan = Sentry.getCurrentHub().startSpan({ + data, + op: 'http', + description: path, + }); + if (!isUndefined(data) && method !== 'GET') { data = JSON.stringify(data); } @@ -259,7 +266,10 @@ export class Client { ...args ); }, - complete: this.wrapCallback(id, options.complete, true), + complete: () => { + Sentry.getCurrentHub().finishSpan(requestSpan); + return this.wrapCallback(id, options.complete, true); + }, }) ); diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index dcb332d4b8ed2a..cc478a524adc00 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -32,7 +32,6 @@ Sentry.init({ }), new Tracing({ tracingOrigins: ['localhost', 'sentry.io', /^\//], - autoStartOnDomReady: false, }), ], }); @@ -46,6 +45,40 @@ Sentry.configureScope(scope => { } }); +// APM -------------------------------------------------------------- +let flushTransactionTimeout = undefined; + +Router.browserHistory.listen(location => { + if (location && location.action === 'REPLACE') { + // If there was already an ongoing transaction, we flush it + const currentScope = Sentry.getCurrentHub().getScope(); + if (currentScope) { + const prevTransactionSpan = currentScope.getSpan(); + // If there is a transaction we set the name to the route + if (prevTransactionSpan) { + Sentry.getCurrentHub().finishSpan(prevTransactionSpan); + } + } + + // We do set the transaction name in the router but we want to start it here + // since in the App component where we set the transaction name, it's called multiple + // times. This would result in loosing the start of the transaction. + const transactionSpan = Sentry.getCurrentHub().startSpan(); + + Sentry.getCurrentHub().configureScope(scope => { + scope.setSpan(transactionSpan); + }); + + if (flushTransactionTimeout) { + clearTimeout(flushTransactionTimeout); + } + + flushTransactionTimeout = setTimeout(() => { + Sentry.getCurrentHub().finishSpan(transactionSpan); + }, 5000); + } +}); + // ----------------------------------------------------------------- // Used for operational metrics to determine that the application js diff --git a/src/sentry/static/sentry/app/views/app.jsx b/src/sentry/static/sentry/app/views/app.jsx index 6bdc989ca58acb..a5fafc586ef751 100644 --- a/src/sentry/static/sentry/app/views/app.jsx +++ b/src/sentry/static/sentry/app/views/app.jsx @@ -1,6 +1,5 @@ import $ from 'jquery'; import {ThemeProvider} from 'emotion-theming'; -import {Tracing} from '@sentry/integrations'; import {browserHistory} from 'react-router'; import {get, isEqual} from 'lodash'; import {getCurrentHub} from '@sentry/browser'; @@ -158,7 +157,6 @@ class App extends React.Component { } componentDidMount() { - this.updateTracing(); fetchGuides(); } @@ -167,7 +165,6 @@ class App extends React.Component { if (!isEqual(config, prevProps.config)) { this.handleConfigStoreChange(config); } - this.updateTracing(); } @@ -177,7 +174,14 @@ class App extends React.Component { updateTracing() { const route = getRouteStringFromRoutes(this.props.routes); - Tracing.startTrace(getCurrentHub(), route); + const scope = getCurrentHub().getScope(); + if (scope) { + const transactionSpan = scope.getSpan(); + // If there is a transaction we set the name to the route + if (transactionSpan) { + transactionSpan.transaction = route; + } + } } handleConfigStoreChange(config) { From 9f512353f50bd1f3eabb8b78afe2f86e4a54ef63 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 16 Jul 2019 13:58:51 +0200 Subject: [PATCH 02/12] fix: Create inital transaction --- src/sentry/static/sentry/app/bootstrap.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index cc478a524adc00..52c7a7f1acb069 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -43,6 +43,13 @@ Sentry.configureScope(scope => { if (window.__SENTRY__VERSION) { scope.setTag('sentry_version', window.__SENTRY__VERSION); } + // TODO(daniel): Maybe we need to follows from + // This is the inital pageload span + scope.setSpan( + Sentry.getCurrentHub().startSpan({ + op: 'pageload', + }) + ); }); // APM -------------------------------------------------------------- From c8ecbb4bf38faf8098aa90dedb4cc7d7bd7f9746 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 16 Jul 2019 14:40:52 +0200 Subject: [PATCH 03/12] fix: Add sampled true --- src/sentry/static/sentry/app/bootstrap.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index 52c7a7f1acb069..395769d69f3f1d 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -48,6 +48,7 @@ Sentry.configureScope(scope => { scope.setSpan( Sentry.getCurrentHub().startSpan({ op: 'pageload', + sampled: true }) ); }); From 0aba5084cddd62cd48c92ffaa9573000dea35d33 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 16 Jul 2019 15:07:12 +0200 Subject: [PATCH 04/12] feat: Fix inital page load span --- src/sentry/static/sentry/app/bootstrap.jsx | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index 395769d69f3f1d..67c2db0fad1ba6 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -48,32 +48,33 @@ Sentry.configureScope(scope => { scope.setSpan( Sentry.getCurrentHub().startSpan({ op: 'pageload', - sampled: true + sampled: true, }) ); }); // APM -------------------------------------------------------------- let flushTransactionTimeout = undefined; +let firstPageLoad = true; Router.browserHistory.listen(location => { if (location && location.action === 'REPLACE') { - // If there was already an ongoing transaction, we flush it - const currentScope = Sentry.getCurrentHub().getScope(); - if (currentScope) { - const prevTransactionSpan = currentScope.getSpan(); - // If there is a transaction we set the name to the route - if (prevTransactionSpan) { - Sentry.getCurrentHub().finishSpan(prevTransactionSpan); - } - } - // We do set the transaction name in the router but we want to start it here // since in the App component where we set the transaction name, it's called multiple // times. This would result in loosing the start of the transaction. - const transactionSpan = Sentry.getCurrentHub().startSpan(); - + let transactionSpan; Sentry.getCurrentHub().configureScope(scope => { + if (firstPageLoad) { + transactionSpan = scope.getSpan(); + firstPageLoad = false; + } else { + const prevTransactionSpan = scope.getSpan(); + // If there is a transaction we set the name to the route + if (prevTransactionSpan) { + Sentry.getCurrentHub().finishSpan(prevTransactionSpan); + } + transactionSpan = Sentry.getCurrentHub().startSpan(); + } scope.setSpan(transactionSpan); }); From a9df2ab85c02320e9dc6eb0687db2afe15663225 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 16 Jul 2019 15:22:39 +0200 Subject: [PATCH 05/12] fix: Pageload + Navigation transaction --- src/sentry/static/sentry/app/bootstrap.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index 67c2db0fad1ba6..7bb5a0b7d6b2cc 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -70,10 +70,13 @@ Router.browserHistory.listen(location => { } else { const prevTransactionSpan = scope.getSpan(); // If there is a transaction we set the name to the route - if (prevTransactionSpan) { + if (prevTransactionSpan && prevTransactionSpan.timestamp === undefined) { Sentry.getCurrentHub().finishSpan(prevTransactionSpan); } - transactionSpan = Sentry.getCurrentHub().startSpan(); + transactionSpan = Sentry.getCurrentHub().startSpan({ + op: 'navigation', + sampled: true, + }); } scope.setSpan(transactionSpan); }); From 55c437c49ac9b823db1cf254b76c3784fcec973b Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Wed, 17 Jul 2019 10:22:11 +0200 Subject: [PATCH 06/12] fix: Add traceparent_v2 --- src/sentry/utils/sdk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sentry/utils/sdk.py b/src/sentry/utils/sdk.py index e5bdd3d4ecb316..326a3617bc6768 100644 --- a/src/sentry/utils/sdk.py +++ b/src/sentry/utils/sdk.py @@ -109,6 +109,7 @@ def capture_event(event): RustInfoIntegration(), ], transport=capture_event, + traceparent_v2=True, **options ) From 72c5d12d8a39d7dcdbd3bdef3c3ea0b6925f2638 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Wed, 17 Jul 2019 11:57:30 +0200 Subject: [PATCH 07/12] ref: CodeReview changes + history change fix --- src/sentry/static/sentry/app/api.jsx | 5 +- src/sentry/static/sentry/app/bootstrap.jsx | 60 ++++++++++++---------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/sentry/static/sentry/app/api.jsx b/src/sentry/static/sentry/app/api.jsx index ecec8e59ae626f..dcc85ce3f22842 100644 --- a/src/sentry/static/sentry/app/api.jsx +++ b/src/sentry/static/sentry/app/api.jsx @@ -180,7 +180,8 @@ export class Client { const id = uniqueId(); metric.mark(`api-request-start-${id}`); - const requestSpan = Sentry.getCurrentHub().startSpan({ + const hub = Sentry.getCurrentHub(); + const requestSpan = hub.startSpan({ data, op: 'http', description: path, @@ -267,7 +268,7 @@ export class Client { ); }, complete: () => { - Sentry.getCurrentHub().finishSpan(requestSpan); + hub.finishSpan(requestSpan); return this.wrapCallback(id, options.complete, true); }, }) diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index 7bb5a0b7d6b2cc..dbd076e5f18935 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -57,38 +57,42 @@ Sentry.configureScope(scope => { let flushTransactionTimeout = undefined; let firstPageLoad = true; -Router.browserHistory.listen(location => { - if (location && location.action === 'REPLACE') { - // We do set the transaction name in the router but we want to start it here - // since in the App component where we set the transaction name, it's called multiple - // times. This would result in loosing the start of the transaction. - let transactionSpan; - Sentry.getCurrentHub().configureScope(scope => { - if (firstPageLoad) { - transactionSpan = scope.getSpan(); - firstPageLoad = false; - } else { - const prevTransactionSpan = scope.getSpan(); - // If there is a transaction we set the name to the route - if (prevTransactionSpan && prevTransactionSpan.timestamp === undefined) { - Sentry.getCurrentHub().finishSpan(prevTransactionSpan); - } - transactionSpan = Sentry.getCurrentHub().startSpan({ - op: 'navigation', - sampled: true, - }); +function trackTrace() { + // We do set the transaction name in the router but we want to start it here + // since in the App component where we set the transaction name, it's called multiple + // times. This would result in losing the start of the transaction. + let transactionSpan; + const hub = Sentry.getCurrentHub(); + hub.configureScope(scope => { + if (firstPageLoad) { + transactionSpan = scope.getSpan(); + firstPageLoad = false; + } else { + const prevTransactionSpan = scope.getSpan(); + // If there is a transaction we set the name to the route + if (prevTransactionSpan && prevTransactionSpan.timestamp === undefined) { + hub.finishSpan(prevTransactionSpan); } - scope.setSpan(transactionSpan); - }); - - if (flushTransactionTimeout) { - clearTimeout(flushTransactionTimeout); + transactionSpan = hub.startSpan({ + op: 'navigation', + sampled: true, + }); } + scope.setSpan(transactionSpan); + }); - flushTransactionTimeout = setTimeout(() => { - Sentry.getCurrentHub().finishSpan(transactionSpan); - }, 5000); + if (flushTransactionTimeout) { + clearTimeout(flushTransactionTimeout); } + + flushTransactionTimeout = setTimeout(() => { + hub.finishSpan(transactionSpan); + }, 5000); +} + +trackTrace(); +Router.browserHistory.listen(() => { + trackTrace(); }); // ----------------------------------------------------------------- From cc319c914bc5dae0ae4b42cedcb72547fcbf7295 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 19 Jul 2019 10:33:47 +0200 Subject: [PATCH 08/12] ref: Cleanup --- src/sentry/static/sentry/app/bootstrap.jsx | 60 +++++----------------- src/sentry/static/sentry/app/utils/apm.jsx | 45 ++++++++++++++++ 2 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 src/sentry/static/sentry/app/utils/apm.jsx diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index dbd076e5f18935..7a5d23c1d6becf 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -21,6 +21,7 @@ import ConfigStore from 'app/stores/configStore'; import Main from 'app/main'; import ajaxCsrfSetup from 'app/utils/ajaxCsrfSetup'; import plugins from 'app/plugins'; +import {startApm} from 'app/utils/apm'; // SDK INIT -------------------------------------------------------- Sentry.init({ @@ -43,8 +44,6 @@ Sentry.configureScope(scope => { if (window.__SENTRY__VERSION) { scope.setTag('sentry_version', window.__SENTRY__VERSION); } - // TODO(daniel): Maybe we need to follows from - // This is the inital pageload span scope.setSpan( Sentry.getCurrentHub().startSpan({ op: 'pageload', @@ -53,50 +52,6 @@ Sentry.configureScope(scope => { ); }); -// APM -------------------------------------------------------------- -let flushTransactionTimeout = undefined; -let firstPageLoad = true; - -function trackTrace() { - // We do set the transaction name in the router but we want to start it here - // since in the App component where we set the transaction name, it's called multiple - // times. This would result in losing the start of the transaction. - let transactionSpan; - const hub = Sentry.getCurrentHub(); - hub.configureScope(scope => { - if (firstPageLoad) { - transactionSpan = scope.getSpan(); - firstPageLoad = false; - } else { - const prevTransactionSpan = scope.getSpan(); - // If there is a transaction we set the name to the route - if (prevTransactionSpan && prevTransactionSpan.timestamp === undefined) { - hub.finishSpan(prevTransactionSpan); - } - transactionSpan = hub.startSpan({ - op: 'navigation', - sampled: true, - }); - } - scope.setSpan(transactionSpan); - }); - - if (flushTransactionTimeout) { - clearTimeout(flushTransactionTimeout); - } - - flushTransactionTimeout = setTimeout(() => { - hub.finishSpan(transactionSpan); - }, 5000); -} - -trackTrace(); -Router.browserHistory.listen(() => { - trackTrace(); -}); - -// ----------------------------------------------------------------- - // Used for operational metrics to determine that the application js // bundle was loaded by browser. metric.mark('sentry-app-init'); @@ -112,6 +67,19 @@ if (window.__initialData) { ConfigStore.loadInitialData(window.__initialData); } +// APM ------------------------------------------------------------- +const config = ConfigStore.getConfig(); +// This is just a simple gatekeeper to not enable apm for whole sentry.io at first +if ( + config && + config.userIdentity && + config.userIdentity.email && + config.userIdentity.email.includes('sentry') +) { + startApm(); +} +// ----------------------------------------------------------------- + // these get exported to a global variable, which is important as its the only // way we can call into scoped objects diff --git a/src/sentry/static/sentry/app/utils/apm.jsx b/src/sentry/static/sentry/app/utils/apm.jsx new file mode 100644 index 00000000000000..6fd355dd376946 --- /dev/null +++ b/src/sentry/static/sentry/app/utils/apm.jsx @@ -0,0 +1,45 @@ +import * as Router from 'react-router'; +import * as Sentry from '@sentry/browser'; + +let flushTransactionTimeout = undefined; +let firstPageLoad = true; + +function startTransaction() { + // We do set the transaction name in the router but we want to start it here + // since in the App component where we set the transaction name, it's called multiple + // times. This would result in losing the start of the transaction. + let transactionSpan; + const hub = Sentry.getCurrentHub(); + hub.configureScope(scope => { + if (firstPageLoad) { + transactionSpan = scope.getSpan(); + firstPageLoad = false; + } else { + const prevTransactionSpan = scope.getSpan(); + // If there is a transaction we set the name to the route + if (prevTransactionSpan && prevTransactionSpan.timestamp === undefined) { + hub.finishSpan(prevTransactionSpan); + } + transactionSpan = hub.startSpan({ + op: 'navigation', + sampled: true, + }); + } + scope.setSpan(transactionSpan); + }); + + if (flushTransactionTimeout) { + clearTimeout(flushTransactionTimeout); + } + + flushTransactionTimeout = setTimeout(() => { + hub.finishSpan(transactionSpan); + }, 5000); +} + +export function startApm() { + startTransaction(); + Router.browserHistory.listen(() => { + startTransaction(); + }); +} From 5781c05d12ae9af464e3786687148bbe2af4a8b5 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 19 Jul 2019 14:17:22 +0200 Subject: [PATCH 09/12] feat: Use beta sdk for apm, Add localhost to enable apm --- package.json | 4 +- src/sentry/static/sentry/app/bootstrap.jsx | 8 +- yarn.lock | 86 +++++++++++----------- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 9e7f24ad423d69..d162d503b1525e 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.3.3", "@babel/runtime": "^7.0.0", - "@sentry/browser": "^5.4.2", - "@sentry/integrations": "^5.4.2", + "@sentry/browser": "5.6.0-beta.0", + "@sentry/integrations": "5.6.0-beta.0", "@sentry/typescript": "^5.3.0", "@types/lodash": "^4.14.134", "@types/react-dom": "^16.8.4", diff --git a/src/sentry/static/sentry/app/bootstrap.jsx b/src/sentry/static/sentry/app/bootstrap.jsx index 7a5d23c1d6becf..34c42575676c6f 100644 --- a/src/sentry/static/sentry/app/bootstrap.jsx +++ b/src/sentry/static/sentry/app/bootstrap.jsx @@ -72,9 +72,11 @@ const config = ConfigStore.getConfig(); // This is just a simple gatekeeper to not enable apm for whole sentry.io at first if ( config && - config.userIdentity && - config.userIdentity.email && - config.userIdentity.email.includes('sentry') + ((config.userIdentity && + config.userIdentity.email && + config.userIdentity.email.includes('sentry')) || + (config.urlPrefix && + (config.urlPrefix.includes('localhost') || config.urlPrefix.includes('127.0.0.1')))) ) { startApm(); } diff --git a/yarn.lock b/yarn.lock index 2ae67f5dee32f9..099673c2f8b18f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1182,58 +1182,58 @@ hey-listen "^1.0.8" style-value-types "^3.1.4" -"@sentry/browser@^5.4.2": - version "5.4.3" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.4.3.tgz#c9b56611c6b7de624962d2ea3fc0a9318f44a853" - integrity sha512-5fPlco0/65RpyNy9LMURrZhX1RT1+CAoR06yU65ZB81N3oRuAGDYE85Hs62t0T3EEGTKrMundINHcq8UD1V0xw== - dependencies: - "@sentry/core" "5.4.3" - "@sentry/types" "5.4.2" - "@sentry/utils" "5.4.2" +"@sentry/browser@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.6.0-beta.0.tgz#b0524305d618b4e228567939dbd3fadb69fbdd9f" + integrity sha512-/tRVsZoqvsMFGNyg9OBEn1RoWtoFGMTOx6IFHqbTRwlrfyaF0JKhTbHVzj7RahGeOJBrKYePbgv5JKyT1fqNEw== + dependencies: + "@sentry/core" "5.6.0-beta.0" + "@sentry/types" "5.6.0-beta.0" + "@sentry/utils" "5.6.0-beta.0" tslib "^1.9.3" -"@sentry/core@5.4.3": - version "5.4.3" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.4.3.tgz#c9e3a6cc9f5e296c5a5e19a7a925d9ee9125a95f" - integrity sha512-VjRv9BXip2BtCSohi/WQra+Ep4B8ajer1nU1VpKy5tUCjpVfXRpitY23EdEl+MVJH7h6YPZ45JsuFiKGgrtaFQ== +"@sentry/core@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.6.0-beta.0.tgz#0c1d7ac47ff0e2fb1c6b9e06fd233641e2514d50" + integrity sha512-gy6BfCR+ITzgfoUbSfiGFyBC3I+Jmqf/CObh5FRjYWFbKAnZ0+YLWJWmerGNtojFmpvo2R8yhlgd0glHAiSGEQ== dependencies: - "@sentry/hub" "5.4.3" - "@sentry/minimal" "5.4.3" - "@sentry/types" "5.4.2" - "@sentry/utils" "5.4.2" + "@sentry/hub" "5.6.0-beta.0" + "@sentry/minimal" "5.6.0-beta.0" + "@sentry/types" "5.6.0-beta.0" + "@sentry/utils" "5.6.0-beta.0" tslib "^1.9.3" -"@sentry/hub@5.4.3": - version "5.4.3" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.4.3.tgz#d6936f976435dd552e06a6a3e9f8cd643e9b9b3f" - integrity sha512-97bnk2dDuCdFv2xhujogqPiDDpKOsHxBXH1jOJ5ezr3/uZNsMRr450FDxxJJYDLuSx+qZ/+vUFfdVNjprBsuSg== +"@sentry/hub@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.6.0-beta.0.tgz#907c46c726d9eb90b9748d7077dfdefbcc0ef6c2" + integrity sha512-IAIeEpduPrWwU+CVNYgTVBrfu+h3ZO7s86eQaaC1P+WcL2fux2qrFQ+PaJnumh5iPdozE1SG2GnhK2oPfKpKrQ== dependencies: - "@sentry/types" "5.4.2" - "@sentry/utils" "5.4.2" + "@sentry/types" "5.6.0-beta.0" + "@sentry/utils" "5.6.0-beta.0" tslib "^1.9.3" -"@sentry/integrations@^5.4.2": - version "5.4.2" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.4.2.tgz#75312407571392badc40ee48b031fae701fee564" - integrity sha512-+nPaFdj8v2EBkZsQBF/pOIwqcf32//R3Iz37aMAWuutw0YOgJXJEaPe4GNMpk78bH3ZwVltGlW8RsDD6zgcc7A== +"@sentry/integrations@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.6.0-beta.0.tgz#63a94ac1281839923b2d7b63c515d1576d8cf368" + integrity sha512-bjO/3jPRF2irS4ykkujiOo96nF4nMPObn8kb87p9d83G035/r5E5BqQ6fVDfyjerVbE6pDUWEAFm8dusM5/+TA== dependencies: - "@sentry/types" "5.4.2" - "@sentry/utils" "5.4.2" + "@sentry/types" "5.6.0-beta.0" + "@sentry/utils" "5.6.0-beta.0" tslib "^1.9.3" -"@sentry/minimal@5.4.3": - version "5.4.3" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.4.3.tgz#afaa8f7a3b5074efa8d70a2edac920b2e0cdbe15" - integrity sha512-xSCcKDtVtlmJIGmnlNH2fL++4l7iORJ+pOOfTz1Yjm/Il7Tz9wLVodbEfplXmAbOvgG/x9oilbW0MBSnrwKPfQ== +"@sentry/minimal@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.6.0-beta.0.tgz#9e487adf76c6eb0d2d1f653e67dada3d3ca57866" + integrity sha512-aL4nKcWmuq7FIZlnmDQkBbh+pZZEOZXaoQihKqpoP9nAMO+9hXlHo5RqqxW5WoHFBSG3PElZ/BD1Ia13uLNg0Q== dependencies: - "@sentry/hub" "5.4.3" - "@sentry/types" "5.4.2" + "@sentry/hub" "5.6.0-beta.0" + "@sentry/types" "5.6.0-beta.0" tslib "^1.9.3" -"@sentry/types@5.4.2": - version "5.4.2" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.4.2.tgz#4ab327bced2cfd961dc7a29f0ff43398f913f6a6" - integrity sha512-yh1fd7x5lLOIZ8W3A1I792B3jowJVCWp4HcTRikjTsjbF8lcURY62m+hiLYUFPTIX99AlFRIPiApDkWiwMGYMA== +"@sentry/types@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.6.0-beta.0.tgz#387faa0d122088ff9828bd35df28301b2ec89162" + integrity sha512-QWuw7YlS8Q2vIBfH35P/sIk916bJ3wuPcwN71pmAFlCDlcv9UN+pPStW/en2S68dt2hwvSUN9HjtzDlN1Vdgtg== "@sentry/typescript@^5.3.0": version "5.3.0" @@ -1243,12 +1243,12 @@ tslint-config-prettier "^1.18.0" tslint-consistent-codestyle "^1.15.1" -"@sentry/utils@5.4.2": - version "5.4.2" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.4.2.tgz#c88c6c08d635e1744a443cfefe9e2ed7fa250e4e" - integrity sha512-AW7/TGt2HiPQB8lJ8NgMgaFAIDQpKDF+wV8nENRbC1CP1zzcvb1QBF4zBL2auDT4fhkhVa817064s7vlDiJVLQ== +"@sentry/utils@5.6.0-beta.0": + version "5.6.0-beta.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.6.0-beta.0.tgz#784fe659b49f2c39c52cf782e03d9e9f4da99fe8" + integrity sha512-NnvpyDswCd4uWMplalGTnAvB4ByU5XrOqlahLa5XSjOq833/UO5eooCrylMH5h7r272D9rmDxCyZuxapnuhisw== dependencies: - "@sentry/types" "5.4.2" + "@sentry/types" "5.6.0-beta.0" tslib "^1.9.3" "@storybook/addon-a11y@^4.1.3": From 5c203d7ddb450b8f1b19444392fd5ca7471198b3 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 19 Jul 2019 17:11:55 +0200 Subject: [PATCH 10/12] Apply suggestions from code review Co-Authored-By: Alberto Leal --- src/sentry/static/sentry/app/api.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sentry/static/sentry/app/api.jsx b/src/sentry/static/sentry/app/api.jsx index 3c617833151803..a9d30fa0bad6a7 100644 --- a/src/sentry/static/sentry/app/api.jsx +++ b/src/sentry/static/sentry/app/api.jsx @@ -267,9 +267,9 @@ export class Client { ...args ); }, - complete: () => { + complete: (...args) => { hub.finishSpan(requestSpan); - return this.wrapCallback(id, options.complete, true); + return this.wrapCallback(id, options.complete, true)(...args); }, }) ); From 81a9522e55c1ce63d8891141ffd0da76a7654a33 Mon Sep 17 00:00:00 2001 From: HazA Date: Fri, 19 Jul 2019 17:17:00 +0200 Subject: [PATCH 11/12] ref: CR --- src/sentry/static/sentry/app/api.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sentry/static/sentry/app/api.jsx b/src/sentry/static/sentry/app/api.jsx index a9d30fa0bad6a7..a0f16c55be915d 100644 --- a/src/sentry/static/sentry/app/api.jsx +++ b/src/sentry/static/sentry/app/api.jsx @@ -163,6 +163,13 @@ export class Client { } request(path, options = {}) { + const hub = Sentry.getCurrentHub(); + const requestSpan = hub.startSpan({ + data, + op: 'http', + description: path, + }); + let query; try { query = $.param(options.query || [], true); @@ -180,13 +187,6 @@ export class Client { const id = uniqueId(); metric.mark(`api-request-start-${id}`); - const hub = Sentry.getCurrentHub(); - const requestSpan = hub.startSpan({ - data, - op: 'http', - description: path, - }); - if (!isUndefined(data) && method !== 'GET') { data = JSON.stringify(data); } From 3a68e2958fe0d5d0652be2af2c2786549f3e560b Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Mon, 22 Jul 2019 09:42:39 +0200 Subject: [PATCH 12/12] cr: Minor code changes --- src/sentry/static/sentry/app/api.jsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/sentry/static/sentry/app/api.jsx b/src/sentry/static/sentry/app/api.jsx index a0f16c55be915d..0a46e102d9919a 100644 --- a/src/sentry/static/sentry/app/api.jsx +++ b/src/sentry/static/sentry/app/api.jsx @@ -163,11 +163,20 @@ export class Client { } request(path, options = {}) { + const method = options.method || (options.data ? 'POST' : 'GET'); + let data = options.data; + + if (!isUndefined(data) && method !== 'GET') { + data = JSON.stringify(data); + } + const hub = Sentry.getCurrentHub(); const requestSpan = hub.startSpan({ - data, + data: { + request_data: data, + }, op: 'http', - description: path, + description: `${method} ${path}`, }); let query; @@ -182,15 +191,9 @@ export class Client { throw err; } - const method = options.method || (options.data ? 'POST' : 'GET'); - let data = options.data; const id = uniqueId(); metric.mark(`api-request-start-${id}`); - if (!isUndefined(data) && method !== 'GET') { - data = JSON.stringify(data); - } - let fullUrl; if (path.indexOf(this.baseUrl) === -1) { fullUrl = this.baseUrl + path;