Skip to content

Commit 72f5006

Browse files
committed
fix tests
1 parent 52b7884 commit 72f5006

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/core/src/utils-hoist/url.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export function getHttpSpanDetailsFromUrlObject(
164164
};
165165

166166
if (routeName) {
167-
attributes[kind === 'client' ? 'http.route' : 'url.route'] = routeName;
167+
// This is based on https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name
168+
attributes[kind === 'server' ? 'http.route' : 'url.template'] = routeName;
168169
attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] = 'route';
169170
}
170171

packages/core/test/utils-hoist/url.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
420420
it('handles absolute URL object', () => {
421421
const urlObject = parseStringToURLObject('https://example.com/api/users?q=test#section')!;
422422
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
423-
expect(name).toBe('GET https://example.com/api/users');
423+
expect(name).toBe('GET /api/users');
424424
expect(attributes).toEqual({
425425
'sentry.origin': 'test-origin',
426426
'sentry.source': 'url',
@@ -436,7 +436,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
436436
it('handles URL object with request method', () => {
437437
const urlObject = parseStringToURLObject('https://example.com/api/users')!;
438438
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin', { method: 'POST' });
439-
expect(name).toBe('POST https://example.com/api/users');
439+
expect(name).toBe('POST /api/users');
440440
expect(attributes).toEqual({
441441
'sentry.origin': 'test-origin',
442442
'sentry.source': 'url',
@@ -472,7 +472,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
472472
it('handles root path URL', () => {
473473
const urlObject = parseStringToURLObject('https://example.com/')!;
474474
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
475-
expect(name).toBe('GET https://example.com/');
475+
expect(name).toBe('GET /');
476476
expect(attributes).toEqual({
477477
'sentry.origin': 'test-origin',
478478
'sentry.source': 'route',
@@ -486,7 +486,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
486486
it('handles URL with port', () => {
487487
const urlObject = parseStringToURLObject('https://example.com:8080/api/users')!;
488488
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
489-
expect(name).toBe('GET https://example.com:8080/api/users');
489+
expect(name).toBe('GET /api/users');
490490
expect(attributes).toEqual({
491491
'sentry.origin': 'test-origin',
492492
'sentry.source': 'url',
@@ -501,7 +501,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
501501
it('handles URL with non-standard port and request method', () => {
502502
const urlObject = parseStringToURLObject('https://example.com:3000/api/users')!;
503503
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin', { method: 'PUT' });
504-
expect(name).toBe('PUT https://example.com:3000/api/users');
504+
expect(name).toBe('PUT /api/users');
505505
expect(attributes).toEqual({
506506
'sentry.origin': 'test-origin',
507507
'sentry.source': 'url',
@@ -583,7 +583,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
583583
it('handles URL with auth credentials', () => {
584584
const urlObject = parseStringToURLObject('https://user:[email protected]/api/users')!;
585585
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
586-
expect(name).toBe('GET https://%filtered%:%filtered%@example.com/api/users');
586+
expect(name).toBe('GET /api/users');
587587
expect(attributes).toEqual({
588588
'sentry.origin': 'test-origin',
589589
'sentry.source': 'url',
@@ -597,7 +597,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
597597
it('handles URL with IPv4 address', () => {
598598
const urlObject = parseStringToURLObject('https://192.168.1.1:8080/api/users')!;
599599
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
600-
expect(name).toBe('GET https://192.168.1.1:8080/api/users');
600+
expect(name).toBe('GET /api/users');
601601
expect(attributes).toEqual({
602602
'sentry.origin': 'test-origin',
603603
'sentry.source': 'url',
@@ -612,7 +612,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
612612
it('handles URL with IPv6 address', () => {
613613
const urlObject = parseStringToURLObject('https://[2001:db8::1]:8080/api/users')!;
614614
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
615-
expect(name).toBe('GET https://[2001:db8::1]:8080/api/users');
615+
expect(name).toBe('GET /api/users');
616616
expect(attributes).toEqual({
617617
'sentry.origin': 'test-origin',
618618
'sentry.source': 'url',
@@ -627,7 +627,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
627627
it('handles URL with subdomain', () => {
628628
const urlObject = parseStringToURLObject('https://api.example.com/users')!;
629629
const [name, attributes] = getHttpSpanDetailsFromUrlObject(urlObject, 'server', 'test-origin');
630-
expect(name).toBe('GET https://api.example.com/users');
630+
expect(name).toBe('GET /users');
631631
expect(attributes).toEqual({
632632
'sentry.origin': 'test-origin',
633633
'sentry.source': 'url',

0 commit comments

Comments
 (0)