Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8df443

Browse files
committed
small adjustments & fixes
1 parent 6627226 commit a8df443

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

‎packages/node-core/src/integrations/http/httpServerIntegration.ts‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import {
1818
} from '@sentry/core';
1919
import { DEBUG_BUILD } from '../../debug-build';
2020
import type { NodeClient } from '../../sdk/client';
21-
import { INSTRUMENTATION_NAME,MAX_BODY_BYTE_LENGTH } from './constants';
21+
import { MAX_BODY_BYTE_LENGTH } from './constants';
2222

2323
type ServerEmit = typeof Server.prototype.emit;
2424

2525
const HTTP_SERVER_INSTRUMENTED_KEY = createContextKey('sentry_http_server_instrumented');
26+
const INTEGRATION_NAME = 'Http.Server';
2627

2728
interface ServerCallbackOptions {
2829
request: IncomingMessage;
@@ -94,7 +95,7 @@ const _httpServerIntegration = ((options: HttpServerIntegrationOptions = {}) =>
9495
};
9596

9697
return {
97-
name: 'HttpServer',
98+
name: INTEGRATION_NAME,
9899
setupOnce() {
99100
const onHttpServerRequestStart = ((_data: unknown) => {
100101
const data = _data as { server: Server };
@@ -166,7 +167,7 @@ function instrumentServer(
166167
return target.apply(thisArg, args);
167168
}
168169

169-
DEBUG_BUILD && debug.log(INSTRUMENTATION_NAME, 'Handling incoming request');
170+
DEBUG_BUILD && debug.log(INTEGRATION_NAME, 'Handling incoming request');
170171

171172
const isolationScope = getIsolationScope().clone();
172173
const request = args[1] as IncomingMessage;
@@ -335,7 +336,7 @@ function patchRequestToCaptureBody(
335336
let bodyByteLength = 0;
336337
const chunks: Buffer[] = [];
337338

338-
DEBUG_BUILD && debug.log(INSTRUMENTATION_NAME, 'Patching request.on');
339+
DEBUG_BUILD && debug.log(INTEGRATION_NAME, 'Patching request.on');
339340

340341
/**
341342
* We need to keep track of the original callbacks, in order to be able to remove listeners again.
@@ -359,7 +360,7 @@ function patchRequestToCaptureBody(
359360

360361
if (event === 'data') {
361362
DEBUG_BUILD &&
362-
debug.log(INSTRUMENTATION_NAME, `Handling request.on("data") with maximum body size of ${maxBodySize}b`);
363+
debug.log(INTEGRATION_NAME, `Handling request.on("data") with maximum body size of ${maxBodySize}b`);
363364

364365
const callback = new Proxy(listener, {
365366
apply: (target, thisArg, args: Parameters<typeof listener>) => {
@@ -372,12 +373,12 @@ function patchRequestToCaptureBody(
372373
bodyByteLength += bufferifiedChunk.byteLength;
373374
} else if (DEBUG_BUILD) {
374375
debug.log(
375-
INSTRUMENTATION_NAME,
376+
INTEGRATION_NAME,
376377
`Dropping request body chunk because maximum body length of ${maxBodySize}b is exceeded.`,
377378
);
378379
}
379380
} catch (err) {
380-
DEBUG_BUILD && debug.error(INSTRUMENTATION_NAME, 'Encountered error while storing body chunk.');
381+
DEBUG_BUILD && debug.error(INTEGRATION_NAME, 'Encountered error while storing body chunk.');
381382
}
382383

383384
return Reflect.apply(target, thisArg, args);
@@ -429,13 +430,13 @@ function patchRequestToCaptureBody(
429430
}
430431
} catch (error) {
431432
if (DEBUG_BUILD) {
432-
debug.error(INSTRUMENTATION_NAME, 'Error building captured request body', error);
433+
debug.error(INTEGRATION_NAME, 'Error building captured request body', error);
433434
}
434435
}
435436
});
436437
} catch (error) {
437438
if (DEBUG_BUILD) {
438-
debug.error(INSTRUMENTATION_NAME, 'Error patching request to capture body', error);
439+
debug.error(INTEGRATION_NAME, 'Error patching request to capture body', error);
439440
}
440441
}
441442
}

‎packages/node-core/src/integrations/http/httpServerSpansIntegration.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
debug,
2525
getIsolationScope,
2626
getSpanStatusFromHttpCode,
27+
httpHeadersToSpanAttributes,
2728
parseStringToURLObject,
2829
SEMANTIC_ATTRIBUTE_SENTRY_OP,
2930
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
@@ -32,9 +33,10 @@ import {
3233
} from '@sentry/core';
3334
import { DEBUG_BUILD } from '../../debug-build';
3435
import type { NodeClient } from '../../sdk/client';
35-
import { INSTRUMENTATION_NAME } from './constants';
3636
import { registerServerCallback } from './httpServerIntegration';
3737

38+
const INTEGRATION_NAME = 'Http.ServerSpans';
39+
3840
// Tree-shakable guard to remove all code related to tracing
3941
declare const __SENTRY_TRACING__: boolean;
4042

@@ -101,7 +103,7 @@ const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions
101103
const { requestHook, responseHook, applyCustomAttributesOnSpan } = options.instrumentation ?? {};
102104

103105
return {
104-
name: 'HttpServerSpans',
106+
name: INTEGRATION_NAME,
105107
setup(client: NodeClient) {
106108
// If no tracing, we can just skip everything here
107109
if (typeof __SENTRY_TRACING__ !== 'undefined' && !__SENTRY_TRACING__) {
@@ -122,7 +124,7 @@ const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions
122124
ignoreIncomingRequests,
123125
})
124126
) {
125-
DEBUG_BUILD && debug.log(INSTRUMENTATION_NAME, 'Skipping span creation for incoming request', request.url);
127+
DEBUG_BUILD && debug.log(INTEGRATION_NAME, 'Skipping span creation for incoming request', request.url);
126128
return fn();
127129
}
128130

@@ -142,6 +144,7 @@ const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions
142144
const method = normalizedRequest.method || request.method?.toUpperCase() || 'GET';
143145
const httpTargetWithoutQueryFragment = urlObj ? urlObj.pathname : stripUrlQueryAndFragment(fullUrl);
144146
const bestEffortTransactionName = `${method} ${httpTargetWithoutQueryFragment}`;
147+
const shouldSendDefaultPii = client.getOptions().sendDefaultPii ?? false;
145148

146149
// We use the plain tracer.startSpan here so we can pass the span kind
147150
const span = tracer.startSpan(bestEffortTransactionName, {
@@ -163,6 +166,7 @@ const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions
163166
'http.flavor': httpVersion,
164167
'net.transport': httpVersion?.toUpperCase() === 'QUIC' ? 'ip_udp' : 'ip_tcp',
165168
...getRequestContentLengthAttribute(request),
169+
...httpHeadersToSpanAttributes(normalizedRequest.headers || {}, shouldSendDefaultPii),
166170
},
167171
});
168172

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /