Skip to content

Commit cc645ef

Browse files
authored
feat: Add React Router Instrumentation for Tracing (#20031)
* feat: Use @sentry/tracing * feat: Use react router instrumentation * deps: Update Sentry SDK to 5.20.1
1 parent 49a8676 commit cc645ef

File tree

5 files changed

+110
-160
lines changed

5 files changed

+110
-160
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"@emotion/babel-preset-css-prop": "^10.0.27",
2121
"@emotion/core": "^10.0.27",
2222
"@emotion/styled": "^10.0.27",
23-
"@sentry/apm": "5.19.0",
24-
"@sentry/integrations": "5.19.0",
25-
"@sentry/react": "5.19.0",
23+
"@sentry/tracing": "5.20.1",
24+
"@sentry/integrations": "5.20.1",
25+
"@sentry/react": "5.20.1",
2626
"@sentry/release-parser": "^0.6.0",
2727
"@sentry/rrweb": "^0.1.1",
28-
"@sentry/utils": "5.19.0",
28+
"@sentry/utils": "5.20.1",
2929
"@types/classnames": "^2.2.0",
3030
"@types/clipboard": "^2.0.1",
3131
"@types/color": "^3.0.0",
@@ -132,7 +132,7 @@
132132
"devDependencies": {
133133
"@babel/plugin-transform-react-jsx-source": "^7.2.0",
134134
"@pmmmwh/react-refresh-webpack-plugin": "^0.3.1",
135-
"@sentry/node": "5.19.0",
135+
"@sentry/node": "5.20.1",
136136
"@storybook/addon-a11y": "^5.3.3",
137137
"@storybook/addon-actions": "^5.3.3",
138138
"@storybook/addon-docs": "^5.3.3",

src/sentry/static/sentry/app/bootstrap.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SentryRRWeb from '@sentry/rrweb';
1515
import createReactClass from 'create-react-class';
1616
import jQuery from 'jquery';
1717
import moment from 'moment';
18-
import {Integrations} from '@sentry/apm';
18+
import {Integrations} from '@sentry/tracing';
1919
import {ExtraErrorData} from '@sentry/integrations';
2020
import * as Sentry from '@sentry/react';
2121

@@ -27,7 +27,6 @@ import Main from 'app/main';
2727
import ajaxCsrfSetup from 'app/utils/ajaxCsrfSetup';
2828
import plugins from 'app/plugins';
2929
import routes from 'app/routes';
30-
import {normalizeTransactionName} from 'app/utils/apm';
3130

3231
import {setupFavicon} from './favicon';
3332

@@ -51,23 +50,18 @@ const config = ConfigStore.getConfig();
5150

5251
const tracesSampleRate = config ? config.apmSampling : 0;
5352

54-
const appRoutes = Router.createRoutes(routes());
55-
5653
function getSentryIntegrations(hasReplays: boolean = false) {
5754
const integrations = [
5855
new ExtraErrorData({
5956
// 6 is arbitrary, seems like a nice number
6057
depth: 6,
6158
}),
62-
new Integrations.Tracing({
63-
tracingOrigins: ['localhost', 'sentry.io', /^\//],
64-
debug: {
65-
spanDebugTimingInfo: true,
66-
writeAsBreadcrumbs: false,
67-
},
68-
beforeNavigate: (location: Location) => {
69-
return normalizeTransactionName(appRoutes, location);
70-
},
59+
new Integrations.BrowserTracing({
60+
routingInstrumentation: Sentry.reactRouterV3Instrumentation(
61+
Router.browserHistory,
62+
Router.createRoutes(routes()),
63+
Router.match
64+
),
7165
}),
7266
];
7367
if (hasReplays) {

src/sentry/static/sentry/app/utils/apm.tsx

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/sentry/static/sentry/app/views/app/index.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
} from 'app/actionCreators/deployPreview';
1717
import {fetchGuides} from 'app/actionCreators/guides';
1818
import {openCommandPalette} from 'app/actionCreators/modal';
19-
import {setTransactionName} from 'app/utils/apm';
2019
import {t} from 'app/locale';
2120
import AlertActions from 'app/actions/alertActions';
2221
import ConfigStore from 'app/stores/configStore';
@@ -27,7 +26,6 @@ import Indicators from 'app/components/indicators';
2726
import LoadingIndicator from 'app/components/loadingIndicator';
2827
import NewsletterConsent from 'app/views/newsletterConsent';
2928
import OrganizationsStore from 'app/stores/organizationsStore';
30-
import getRouteStringFromRoutes from 'app/utils/getRouteStringFromRoutes';
3129
import withApi from 'app/utils/withApi';
3230
import withConfig from 'app/utils/withConfig';
3331

@@ -82,8 +80,6 @@ class App extends React.Component<Props, State> {
8280
}
8381

8482
componentDidMount() {
85-
this.updateTracing();
86-
8783
this.props.api.request('/organizations/', {
8884
query: {
8985
member: '1',
@@ -180,7 +176,6 @@ class App extends React.Component<Props, State> {
180176
if (!isEqual(config, prevProps.config)) {
181177
this.handleConfigStoreChange(config);
182178
}
183-
this.updateTracing();
184179
}
185180

186181
componentWillUnmount() {
@@ -189,11 +184,6 @@ class App extends React.Component<Props, State> {
189184

190185
mainContainerRef = React.createRef<HTMLDivElement>();
191186

192-
updateTracing() {
193-
const route = getRouteStringFromRoutes(this.props.routes);
194-
setTransactionName(route);
195-
}
196-
197187
handleConfigStoreChange(config) {
198188
const newState = {} as State;
199189
if (config.needsUpgrade !== undefined) {

0 commit comments

Comments
 (0)