Skip to content

Commit ec81aa4

Browse files
committed
cleanup
1 parent a217919 commit ec81aa4

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

packages/node/src/integrations/http.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ function _createWrappedRequestMethodFactory(
301301
*/
302302
function addRequestBreadcrumb(
303303
event: string,
304-
requestSpanData: RequestSpanData,
304+
requestSpanData: SanitizedRequestData,
305305
req: http.ClientRequest,
306306
res?: http.IncomingMessage,
307307
): void {
@@ -313,7 +313,6 @@ function addRequestBreadcrumb(
313313
{
314314
category: 'http',
315315
data: {
316-
method: req.method,
317316
status_code: res && res.statusCode,
318317
...requestSpanData,
319318
},

packages/sveltekit/src/client/load.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
134134
const [input, init] = args;
135135
const rawUrl = getFetchUrl(args);
136136
const urlObject = new URL(rawUrl);
137-
const sanitizedUrl = getSanitizedUrlString(urlObject);
138-
const method = getFetchMethod(args);
137+
const requestData: SanitizedRequestData = {
138+
url: getSanitizedUrlString(urlObject),
139+
method: getFetchMethod(args),
140+
'http.query': urlObject.search,
141+
'http.fragment': urlObject.hash,
142+
};
139143

140144
// TODO: extract this to a util function (and use it in breadcrumbs integration as well)
141-
if (rawUrl.match(/sentry_key/) && method === 'POST') {
145+
if (rawUrl.match(/sentry_key/)) {
142146
// We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
143147
return wrappingTarget.apply(thisArg, args);
144148
}
@@ -170,19 +174,12 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
170174

171175
let fetchPromise: Promise<Response>;
172176

173-
const spanData: SanitizedRequestData = {
174-
url: sanitizedUrl,
175-
method,
176-
'http.query': urlObject.search,
177-
'http.fragment': urlObject.hash,
178-
};
179-
180177
if (createSpan) {
181178
fetchPromise = trace(
182179
{
183-
name: `${method} ${sanitizedUrl}`, // this will become the description of the span
180+
name: `${requestData.method} ${requestData.url}`, // this will become the description of the span
184181
op: 'http.client',
185-
data: spanData,
182+
data: requestData,
186183
parentSpanId: activeSpan && activeSpan.spanId,
187184
},
188185
async span => {
@@ -198,7 +195,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
198195
}
199196

200197
if (shouldAddFetchBreadcrumbs) {
201-
addFetchBreadcrumb(fetchPromise, spanData, args);
198+
addFetchBreadcrumb(fetchPromise, requestData, args);
202199
}
203200

204201
return fetchPromise;
@@ -209,7 +206,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
209206
/* Adds a breadcrumb for the given fetch result */
210207
function addFetchBreadcrumb(
211208
fetchResult: Promise<Response>,
212-
spanData: SanitizedRequestData,
209+
requestData: SanitizedRequestData,
213210
args: Parameters<SvelteKitFetch>,
214211
): void {
215212
const breadcrumbStartTimestamp = Date.now();
@@ -220,7 +217,7 @@ function addFetchBreadcrumb(
220217
type: 'http',
221218
category: 'fetch',
222219
data: {
223-
...spanData,
220+
...requestData,
224221
status_code: response.status,
225222
},
226223
},
@@ -238,7 +235,7 @@ function addFetchBreadcrumb(
238235
type: 'http',
239236
category: 'fetch',
240237
level: 'error',
241-
data: spanData,
238+
data: requestData,
242239
},
243240
{
244241
input: args,

0 commit comments

Comments
 (0)