Skip to content

Commit

Permalink
Revert "feat: Use new AM SDK API (getsentry#19041)" (getsentry#19059)
Browse files Browse the repository at this point in the history
This reverts commit ffb8518.
  • Loading branch information
HazAT authored May 28, 2020
1 parent ffb8518 commit a302ac0
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 90 deletions.
54 changes: 34 additions & 20 deletions build-utils/sentry-instrumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SentryInstrumentation {

this.initialBuild = false;
this.Sentry = require('@sentry/node');
require('@sentry/apm'); // This is required to patch Sentry
require('@sentry/apm');

this.Sentry.init({
dsn: 'https://[email protected]/2053674',
Expand All @@ -46,6 +46,16 @@ class SentryInstrumentation {
);
}

/**
* Waits for Sentry SDK to finish requests
*/
async sdkFinish() {
const client = this.Sentry.getCurrentHub().getClient();
if (client) {
await client.flush();
}
}

/**
* Measures the file sizes of assets emitted from the entrypoints
*/
Expand All @@ -60,22 +70,20 @@ class SentryInstrumentation {
const asset = compilation.assets[assetName];
const sizeInKb = asset.size() / 1024;

// can also be written as this.Sentry.startTransaction
const transaction = hub.startSpan({
op: 'webpack-asset',
name: assetName,
transaction: assetName,
description: `webpack bundle size for ${entrypointName} -> ${assetName}`,
data: {
entrypointName,
file: assetName,
size: `${Math.round(sizeInKb)} KB`,
},
trimEnd: true,
});

const start = transaction.startTimestamp;

const span = transaction.startChild({
const span = hub.startSpan({
op: 'asset',
startTimestamp: start,
description: assetName,
Expand All @@ -85,8 +93,10 @@ class SentryInstrumentation {
size: `${Math.round(sizeInKb)} KB`,
},
});
span.finish(start + sizeInKb / 1000);
transaction.finish();
span.startTimestamp = start;
span.finish();
span.timestamp = start + sizeInKb / 1000;
transaction.finish(true);
})
)
);
Expand All @@ -96,18 +106,20 @@ class SentryInstrumentation {
if (!this.Sentry) {
return;
}

const hub = this.Sentry.getCurrentHub();

// can also be written as this.Sentry.startTransaction
const transaction = hub.startSpan({
op: 'webpack-build',
name: !this.initialBuild ? 'initial-build' : 'incremental-build',
description: 'webpack build times',
startTimestamp: startTime,
trimEnd: true,
});
const transaction = hub.startSpan(
{
op: 'webpack-build',
transaction: !this.initialBuild ? 'initial-build' : 'incremental-build',
description: 'webpack build times',
},
true
);
transaction.startTimestamp = startTime;

const span = transaction.startChild({
const span = transaction.child({
op: 'build',
description: 'webpack build',
data: {
Expand All @@ -119,10 +131,12 @@ class SentryInstrumentation {
: 'N/A',
loadavg: os.loadavg(),
},
startTimestamp: startTime,
});
span.finish(endTime);
transaction.finish();
span.startTimestamp = startTime;
span.finish();
span.timestamp = endTime;

transaction.finish(true);
}

apply(compiler) {
Expand All @@ -142,7 +156,7 @@ class SentryInstrumentation {
}

this.initialBuild = true;
await this.Sentry.flush();
await this.sdkFinish();
done();
}
);
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"@emotion/babel-preset-css-prop": "^10.0.27",
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@sentry/apm": "5.16.0-beta.4",
"@sentry/browser": "5.16.0-beta.4",
"@sentry/integrations": "5.16.0-beta.4",
"@sentry/apm": "5.16.0-beta.3",
"@sentry/browser": "5.16.0-beta.3",
"@sentry/integrations": "5.16.0-beta.3",
"@sentry/release-parser": "^0.5.0",
"@sentry/rrweb": "^0.1.1",
"@sentry/utils": "5.16.0-beta.4",
"@sentry/utils": "5.16.0-beta.3",
"@types/classnames": "^2.2.0",
"@types/clipboard": "^2.0.1",
"@types/color": "^3.0.0",
Expand Down Expand Up @@ -133,7 +133,7 @@
"devDependencies": {
"@babel/plugin-transform-react-jsx-source": "^7.2.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.3.1",
"@sentry/node": "^5.16.0-beta.4",
"@sentry/node": "^5.16.0-beta.3",
"@storybook/addon-a11y": "^5.3.3",
"@storybook/addon-actions": "^5.3.3",
"@storybook/addon-docs": "^5.3.3",
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/static/sentry/app/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ Sentry.init({
...window.__SENTRY__OPTIONS,
integrations: getSentryIntegrations(hasReplays),
tracesSampleRate,
});

Sentry.addGlobalEventProcessor(async event => {
return normalizeTransactionName(appRoutes, event);
_experiments: {useEnvelope: true},
async beforeSend(event) {
return normalizeTransactionName(appRoutes, event);
},
});

if (window.__SENTRY__USER) {
Expand Down
122 changes: 61 additions & 61 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1823,76 +1823,76 @@
react-lifecycles-compat "^3.0.4"
warning "^3.0.0"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/apm/-/apm-5.16.0-beta.4.tgz#285cc056668a7881e930ccb1197a8968ace659c4"
integrity sha512-hojFb1fxZIVpLbwsuDD1BdWEj1Ax33KBFohZ3kQ14Q5LeGIzMfbKNFlCrtNv+I6+Fe83y22shMXVWVssrIflcw==
dependencies:
"@sentry/browser" "5.16.0-beta.4"
"@sentry/hub" "5.16.0-beta.4"
"@sentry/minimal" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.4"
"@sentry/utils" "5.16.0-beta.4"
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/apm/-/apm-5.16.0-beta.3.tgz#e241cbd9a308e301a681c086e1096b47c04d225a"
integrity sha512-3PmDRh9Hsj+Wfnq5+eWq/RA7CvExlWHCEK2AJZ5pG1WjvWuQ9nj8MXiVNoIA7t2WGujCcEFoDJuUofsMTekdWA==
dependencies:
"@sentry/browser" "5.16.0-beta.3"
"@sentry/hub" "5.16.0-beta.3"
"@sentry/minimal" "5.16.0-beta.3"
"@sentry/types" "5.16.0-beta.3"
"@sentry/utils" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.16.0-beta.4.tgz#6bdedeb7333de00f1641d7cb67992522c950a15b"
integrity sha512-aaSJOj32N8mG+mypMCjFv5wyaPbjx+VLt2z/QOiBpnC3WbV1lRUR0trvUIqq55L4CkcLXB8+6PBG2fS39+MpbA==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-5.16.0-beta.3.tgz#176a0ed01e567c6c0fb59248801b9dcff97e3836"
integrity sha512-mHTrXBSRA9oCG9VukyrB2U6xiqQ2yK5oDsWdt1HDB8ApwOSdOZPfV5TbgfvNa6hEIbLhjbFC0AyQcRgkANveDg==
dependencies:
"@sentry/core" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.4"
"@sentry/utils" "5.16.0-beta.4"
"@sentry/core" "5.16.0-beta.3"
"@sentry/types" "5.16.0-beta.3"
"@sentry/utils" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.16.0-beta.4.tgz#680163ab88c02f1bbb532ac4bfd58e2ec16b6016"
integrity sha512-yhufues9ahGZi7lmB+C5EkORwmxcGXovaFVPvZxr7YgtT9xHwKB1SV0GnP14sQIs0VbiufWNVvHWtUQVN/fIwg==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.16.0-beta.3.tgz#b2a60fb8a81c19f5321a9e3bb17d372aaed74a46"
integrity sha512-9owqHefHt2dv+2bxcic9inneOrji9El9PqkwbRNxIcsduO6+Tu6nFJokBlxUZFi1eKpuAoOjjp0loaYvStKfNw==
dependencies:
"@sentry/hub" "5.16.0-beta.4"
"@sentry/minimal" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.4"
"@sentry/utils" "5.16.0-beta.4"
"@sentry/hub" "5.16.0-beta.3"
"@sentry/minimal" "5.16.0-beta.3"
"@sentry/types" "5.16.0-beta.3"
"@sentry/utils" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.16.0-beta.4.tgz#ac436b901a6bd930973ee99df48ab2c6820784f6"
integrity sha512-QSbYdgr2mE/slPxL9JeXHtmWIybUbpQNlTiWt6gaQyc8H+DsKYzT19AwH32U/4+Z6HC9yk8H0UGpb4HewV1BFw==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.16.0-beta.3.tgz#51c72daa459215654291f38cbdc7e8eb410cfd72"
integrity sha512-yGNnz4nafrjkk6XMDhpAcLwWUGPMShZKOOvYLrBa02Y7mOh+3mBcUaZmGnVA+X1M8idwE72LE1WRkJzBv6t9QA==
dependencies:
"@sentry/types" "5.16.0-beta.4"
"@sentry/utils" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.3"
"@sentry/utils" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.16.0-beta.4.tgz#31b99c9c7465e5f76b3c3020ea02f09b476037a7"
integrity sha512-K4o4QRw93+5AH/lXLWydnCiIhvIWGRd1U6LynJ9qXdHNCCR6E/OYEMnf3t7kOIQuZzFgqrqnr938fwU/edwQeQ==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.16.0-beta.3.tgz#8ecc5018a35b2917225c78dfdcda2d406616336d"
integrity sha512-pC4I1PKK+/FORGElPGFXT7thH3A+xqyPi4QQ8lBLkzKBNn/STvXZhx33nqLGnf6OoihZqpn9GNAGzvGpo7AR2w==
dependencies:
"@sentry/types" "5.16.0-beta.4"
"@sentry/utils" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.3"
"@sentry/utils" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.16.0-beta.4.tgz#cd8e067c336f5d1ef98a121852f567dc80592d5c"
integrity sha512-qcTa1OafWylxhZIRiFVkh4P69BNB7h1syAStSt00o5wnlSSk5xP8u5CORibVVQSN1KbBWljlSyrWY2xKSDXU7A==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.16.0-beta.3.tgz#9340b21e7259f015efbfa932b6f48f42cdf72c0a"
integrity sha512-YUksBXrUp8lRwE40fsWRu6B7YJ/f1d+klyFxyc4ECDCWtByTa80SOwmvwhrApADzFa4g9v/wGXC+KTYybGb3Tg==
dependencies:
"@sentry/hub" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.4"
"@sentry/hub" "5.16.0-beta.3"
"@sentry/types" "5.16.0-beta.3"
tslib "^1.9.3"

"@sentry/node@^5.16.0-beta.4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.16.0-beta.4.tgz#b43fbdee7336108a6b70e38230cbc94bbaabc6aa"
integrity sha512-RiFm7YEJJ5lorqKMbpz/4vUgpNH8OSEJScMNiUTZ1gtysZ5/1YR0lQv536NZkNp2IwjJMThnxKgUrcydTnf2Qg==
"@sentry/node@^5.16.0-beta.3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.16.0-beta.3.tgz#5debe9c29dd9bbaf8acce9d665b2c1d48ab11b3c"
integrity sha512-69cIGhK+0H8PpWizJhvnpbFAoAsSvqGnHUk8tr3VjchdhgVqV1fZSPijqs2VIj/2RUN3r6Hl6XVGLr7Cu1gLmg==
dependencies:
"@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"
"@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"
cookie "^0.3.1"
https-proxy-agent "^4.0.0"
lru_map "^0.3.3"
Expand All @@ -1908,17 +1908,17 @@
resolved "https://registry.yarnpkg.com/@sentry/rrweb/-/rrweb-0.1.1.tgz#1e2ef7381d5c5725ea3bf3ac20987d50eee83dd1"
integrity sha512-bFzZ+NVaGFpkmBvSHsvM/Pc/wiy7UeP/ICofkY2iY5PwiRHpZCX5hLrLYA7o921VR847EKZB44fQYWZC1YFB1Q==

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.16.0-beta.4.tgz#cb59d32ee6f6ea0c4b700dfe8d877f4bbfdad711"
integrity sha512-1aUBt/kmHmB06BjyXFKRg2ra/x2tt/BTUtu4zuezpX8XvtzzBdHt27sxUpDsJCgal1hVyFMer5EaGAISVbNmIg==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.16.0-beta.3.tgz#0658562166aac515977b3a979ced9af01dca153c"
integrity sha512-UfIYazvDhOV/dcfFg8OvA8mR1mcOmRE3m2F6qn2jJiQbccKUSXKsaZRXdk/Dj2c0862VFY+wSxpVgG+Vjb0frQ==

"@sentry/[email protected].4":
version "5.16.0-beta.4"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.16.0-beta.4.tgz#6b591bec35aec79bfbf4d9a056cd3fcccdbf6448"
integrity sha512-VZ2MSqBGEng2On9GywKuntby6JM4C6J+HUVNyBTk03K2GGjkV49bTQrUvbffXRcmvHcGZDic2kXTfV5m+A/hRA==
"@sentry/[email protected].3":
version "5.16.0-beta.3"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.16.0-beta.3.tgz#8d40d2b88e46ad97ac9356f5e627ece23dcb08b0"
integrity sha512-PXFWvC5kSvOSVPlK6xylmPcILNEjBkcBBPmWmvSR8r2he70JmeFDGHkhNP9LaLydcCBZ/eH59bCQqD1sWgTbow==
dependencies:
"@sentry/types" "5.16.0-beta.4"
"@sentry/types" "5.16.0-beta.3"
tslib "^1.9.3"

"@storybook/addon-a11y@^5.3.3":
Expand Down

0 comments on commit a302ac0

Please sign in to comment.