Skip to content

Commit 625b850

Browse files
committed
ref(utils): Stop setting transaction in requestDataIntegration
This is not really necessary anymore - it only sets this on transaction events, and those get the `transaction` in different places already anyhow. With this, we can also actually remove some other stuff. One method is exported from utils but not otherwise used, we can also drop this in v9. Finally, this was also the only place that used `route` on the request, so we can also get rid of this in `remix`, which is weird anyhow because we set it for errors there but don't even use it for them.
1 parent f4c5900 commit 625b850

File tree

3 files changed

+3
-45
lines changed

3 files changed

+3
-45
lines changed

packages/remix/src/utils/errors.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import type { AppData, DataFunctionArgs, EntryContext, HandleDocumentRequestFunction } from '@remix-run/node';
2-
import {
3-
captureException,
4-
getActiveSpan,
5-
getClient,
6-
getRootSpan,
7-
handleCallbackErrors,
8-
spanToJSON,
9-
} from '@sentry/core';
2+
import { captureException, getClient, handleCallbackErrors } from '@sentry/core';
103
import type { Span } from '@sentry/types';
114
import { addExceptionMechanism, isPrimitive, logger, objectify } from '@sentry/utils';
125
import { DEBUG_BUILD } from './debug-build';
@@ -61,19 +54,9 @@ export async function captureRemixServerException(
6154
const objectifiedErr = objectify(err);
6255

6356
captureException(isResponse(objectifiedErr) ? await extractResponseError(objectifiedErr) : objectifiedErr, scope => {
64-
const activeSpan = getActiveSpan();
65-
const rootSpan = activeSpan && getRootSpan(activeSpan);
66-
const activeRootSpanName = rootSpan ? spanToJSON(rootSpan).description : undefined;
67-
6857
scope.setSDKProcessingMetadata({
6958
request: {
7059
...normalizedRequest,
71-
// When `route` is not defined, `RequestData` integration uses the full URL
72-
route: activeRootSpanName
73-
? {
74-
path: activeRootSpanName,
75-
}
76-
: undefined,
7760
},
7861
});
7962

packages/remix/src/utils/instrumentServer.ts

-3
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,6 @@ function wrapRequestHandler(
314314
isolationScope.setSDKProcessingMetadata({
315315
request: {
316316
...normalizedRequest,
317-
route: {
318-
path: name,
319-
},
320317
},
321318
});
322319

packages/utils/src/requestdata.ts

+2-24
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { getClientIPAddress, ipHeaderNames } from './vendor/getIpAddress';
2121
const DEFAULT_INCLUDES = {
2222
ip: false,
2323
request: true,
24-
transaction: true,
2524
user: true,
2625
};
2726
const DEFAULT_REQUEST_INCLUDES = ['cookies', 'data', 'headers', 'method', 'query_string', 'url'];
@@ -35,6 +34,7 @@ export type AddRequestDataToEventOptions = {
3534
include?: {
3635
ip?: boolean;
3736
request?: boolean | Array<(typeof DEFAULT_REQUEST_INCLUDES)[number]>;
37+
/** @deprecated This option will be removed in v9. It does not do anything anymore, the `transcation` is set in other places. */
3838
transaction?: boolean | TransactionNamingScheme;
3939
user?: boolean | Array<(typeof DEFAULT_USER_INCLUDES)[number]>;
4040
};
@@ -67,6 +67,7 @@ export type TransactionNamingScheme = 'path' | 'methodPath' | 'handler';
6767
* used instead of the request's route)
6868
*
6969
* @returns A tuple of the fully constructed transaction name [0] and its source [1] (can be either 'route' or 'url')
70+
* @deprecated This method will be removed in v9. It is not in use anymore.
7071
*/
7172
export function extractPathForTransaction(
7273
req: PolymorphicRequest,
@@ -102,23 +103,6 @@ export function extractPathForTransaction(
102103
return [name, source];
103104
}
104105

105-
function extractTransaction(req: PolymorphicRequest, type: boolean | TransactionNamingScheme): string {
106-
switch (type) {
107-
case 'path': {
108-
return extractPathForTransaction(req, { path: true })[0];
109-
}
110-
case 'handler': {
111-
return (req.route && req.route.stack && req.route.stack[0] && req.route.stack[0].name) || '<anonymous>';
112-
}
113-
case 'methodPath':
114-
default: {
115-
// if exist _reconstructedRoute return that path instead of route.path
116-
const customRoute = req._reconstructedRoute ? req._reconstructedRoute : undefined;
117-
return extractPathForTransaction(req, { path: true, method: true, customRoute })[0];
118-
}
119-
}
120-
}
121-
122106
function extractUserData(
123107
user: {
124108
[key: string]: unknown;
@@ -379,12 +363,6 @@ export function addRequestDataToEvent(
379363
}
380364
}
381365

382-
if (include.transaction && !event.transaction && event.type === 'transaction') {
383-
// TODO do we even need this anymore?
384-
// TODO make this work for nextjs
385-
event.transaction = extractTransaction(req, include.transaction);
386-
}
387-
388366
return event;
389367
}
390368

0 commit comments

Comments
 (0)