Skip to content

Commit ad48785

Browse files
committed
cleanup
1 parent 1525375 commit ad48785

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
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 & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,15 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
133133
const [input, init] = args;
134134
const { url: rawUrl, method } = parseFetchArgs(args);
135135
const urlObject = new URL(rawUrl);
136-
const sanitizedUrl = getSanitizedUrlString(urlObject);
136+
const requestData: SanitizedRequestData = {
137+
url: getSanitizedUrlString(urlObject),
138+
method,
139+
'http.query': urlObject.search,
140+
'http.fragment': urlObject.hash,
141+
};
137142

138143
// TODO: extract this to a util function (and use it in breadcrumbs integration as well)
139-
if (rawUrl.match(/sentry_key/) && method === 'POST') {
144+
if (rawUrl.match(/sentry_key/)) {
140145
// We don't create spans or breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)
141146
return wrappingTarget.apply(thisArg, args);
142147
}
@@ -168,19 +173,12 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
168173

169174
let fetchPromise: Promise<Response>;
170175

171-
const spanData: SanitizedRequestData = {
172-
url: sanitizedUrl,
173-
method,
174-
'http.query': urlObject.search,
175-
'http.fragment': urlObject.hash,
176-
};
177-
178176
if (createSpan) {
179177
fetchPromise = trace(
180178
{
181-
name: `${method} ${sanitizedUrl}`, // this will become the description of the span
179+
name: `${requestData.method} ${requestData.url}`, // this will become the description of the span
182180
op: 'http.client',
183-
data: spanData,
181+
data: requestData,
184182
parentSpanId: activeSpan && activeSpan.spanId,
185183
},
186184
async span => {
@@ -196,7 +194,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
196194
}
197195

198196
if (shouldAddFetchBreadcrumbs) {
199-
addFetchBreadcrumb(fetchPromise, spanData, args);
197+
addFetchBreadcrumb(fetchPromise, requestData, args);
200198
}
201199

202200
return fetchPromise;
@@ -207,7 +205,7 @@ function instrumentSvelteKitFetch(originalFetch: SvelteKitFetch): SvelteKitFetch
207205
/* Adds a breadcrumb for the given fetch result */
208206
function addFetchBreadcrumb(
209207
fetchResult: Promise<Response>,
210-
spanData: SanitizedRequestData,
208+
requestData: SanitizedRequestData,
211209
args: Parameters<SvelteKitFetch>,
212210
): void {
213211
const breadcrumbStartTimestamp = Date.now();
@@ -218,7 +216,7 @@ function addFetchBreadcrumb(
218216
type: 'http',
219217
category: 'fetch',
220218
data: {
221-
...spanData,
219+
...requestData,
222220
status_code: response.status,
223221
},
224222
},
@@ -236,7 +234,7 @@ function addFetchBreadcrumb(
236234
type: 'http',
237235
category: 'fetch',
238236
level: 'error',
239-
data: spanData,
237+
data: requestData,
240238
},
241239
{
242240
input: args,

0 commit comments

Comments
 (0)