Skip to content

Commit 5642fad

Browse files
committed
feat(core): Add server.address to browser http.client spans
1 parent f1c4611 commit 5642fad

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: packages/browser/src/tracing/request.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
addXhrInstrumentationHandler,
55
} from '@sentry-internal/browser-utils';
66
import {
7+
SEMANTIC_ATTRIBUTE_SENTRY_OP,
78
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
89
SentryNonRecordingSpan,
910
getActiveSpan,
@@ -26,6 +27,7 @@ import {
2627
browserPerformanceTimeOrigin,
2728
dynamicSamplingContextToSentryBaggageHeader,
2829
generateSentryTraceHeader,
30+
parseUrl,
2931
stringMatchesSomePattern,
3032
} from '@sentry/utils';
3133
import { WINDOW } from '../helpers';
@@ -310,6 +312,8 @@ export function xhrCallback(
310312

311313
const hasParent = !!getActiveSpan();
312314

315+
const parsedUrl = parseUrl(sentryXhrData.url);
316+
313317
const span =
314318
shouldCreateSpanResult && hasParent
315319
? startInactiveSpan({
@@ -318,9 +322,10 @@ export function xhrCallback(
318322
type: 'xhr',
319323
'http.method': sentryXhrData.method,
320324
url: sentryXhrData.url,
325+
'server.address': parsedUrl.host,
321326
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser',
327+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
322328
},
323-
op: 'http.client',
324329
})
325330
: new SentryNonRecordingSpan();
326331

Diff for: packages/core/src/fetch.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {
44
dynamicSamplingContextToSentryBaggageHeader,
55
generateSentryTraceHeader,
66
isInstanceOf,
7+
parseUrl,
78
} from '@sentry/utils';
89
import { getClient, getCurrentScope, getIsolationScope } from './currentScopes';
9-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
10+
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
1011
import {
1112
SPAN_STATUS_ERROR,
1213
getDynamicSamplingContextFromClient,
@@ -83,6 +84,8 @@ export function instrumentFetchRequest(
8384

8485
const hasParent = !!getActiveSpan();
8586

87+
const parsedUrl = parseUrl(url);
88+
8689
const span =
8790
shouldCreateSpanResult && hasParent
8891
? startInactiveSpan({
@@ -91,9 +94,10 @@ export function instrumentFetchRequest(
9194
url,
9295
type: 'fetch',
9396
'http.method': method,
97+
'server.address': parsedUrl.host,
9498
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
99+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
95100
},
96-
op: 'http.client',
97101
})
98102
: new SentryNonRecordingSpan();
99103

0 commit comments

Comments
 (0)