Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/bun/src/integrations/bunserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ function getSpanAttributesFromParsedUrl(
attributes[URL_PORT] = parsedUrl.port;
}
if (parsedUrl.protocol) {
attributes[URL_SCHEME] = parsedUrl.protocol;
// URL.protocol includes a trailing colon (e.g. 'https:') but the OTel
// url.scheme attribute must not (e.g. 'https').
attributes[URL_SCHEME] = parsedUrl.protocol.replace(':', '');
}
if (parsedUrl.hostname) {
attributes[URL_DOMAIN] = parsedUrl.hostname;
Expand Down
10 changes: 5 additions & 5 deletions packages/bun/test/integrations/bunserver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Bun Serve Integration', () => {
'url.path': '/users',
'url.full': `http://localhost:${port}/users?id=123`,
'url.port': port.toString(),
'url.scheme': 'http:',
'url.scheme': 'http',
'url.domain': 'localhost',
'http.request.header.accept': '*/*',
'http.request.header.accept_encoding': 'gzip, deflate, br, zstd',
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Bun Serve Integration', () => {
'url.path': '/',
'url.full': `http://localhost:${port}/`,
'url.port': port.toString(),
'url.scheme': 'http:',
'url.scheme': 'http',
'url.domain': 'localhost',
'http.request.header.accept': '*/*',
'http.request.header.accept_encoding': 'gzip, deflate, br, zstd',
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Bun Serve Integration', () => {
'url.path': '/api/test',
'url.full': `http://localhost:${port}/api/test`,
'url.port': port.toString(),
'url.scheme': 'http:',
'url.scheme': 'http',
'url.domain': 'localhost',
// HTTP headers as span attributes following OpenTelemetry semantic conventions
'http.request.header.user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('Bun Serve Integration', () => {
'url.path': '/users/123',
'url.full': `http://localhost:${port}/users/123`,
'url.port': port.toString(),
'url.scheme': 'http:',
'url.scheme': 'http',
'url.domain': 'localhost',
}),
op: 'http.server',
Expand Down Expand Up @@ -299,7 +299,7 @@ describe('Bun Serve Integration', () => {
'url.path': '/api/users/123',
'url.full': `http://localhost:${port}/api/users/123`,
'url.port': port.toString(),
'url.scheme': 'http:',
'url.scheme': 'http',
'url.domain': 'localhost',
}),
op: 'http.server',
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ export function getHttpSpanDetailsFromUrlObject(
attributes[URL_PORT] = urlObject.port;
}
if (urlObject.protocol) {
attributes[URL_SCHEME] = urlObject.protocol;
// URL.protocol includes a trailing colon (e.g. 'https:') but the OTel
// url.scheme attribute must not (e.g. 'https').
attributes[URL_SCHEME] = urlObject.protocol.replace(':', '');
}
if (urlObject.hostname) {
attributes[kind === 'server' ? SERVER_ADDRESS : URL_DOMAIN] = urlObject.hostname;
Expand Down
26 changes: 13 additions & 13 deletions packages/core/test/lib/utils/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.fragment': 'section',
'url.full': 'https://example.com/api/users?q=test#section',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
});
});

Expand All @@ -474,7 +474,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://example.com/api/users',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'http.request.method': 'POST',
});
});
Expand All @@ -495,7 +495,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://example.com/api/users',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'http.route': '/api/users/:id',
});
});
Expand All @@ -510,7 +510,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/',
'url.full': 'https://example.com/',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
});
});

Expand All @@ -524,7 +524,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://example.com:8080/api/users',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'url.port': '8080',
});
});
Expand All @@ -539,7 +539,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://example.com:3000/api/users',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'url.port': '3000',
'http.request.method': 'PUT',
});
Expand All @@ -561,7 +561,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users/123',
'url.full': 'https://example.com/api/users/123',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'http.route': '/api/users/:id',
'http.request.method': 'PATCH',
});
Expand All @@ -584,7 +584,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.query': 'q=test&page=1',
'url.full': 'https://example.com/api/search?q=test&page=1',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'http.route': '/api/search',
});
});
Expand All @@ -606,7 +606,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.fragment': 'section-1',
'url.full': 'https://example.com/api/docs#section-1',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
'http.route': '/api/docs',
});
});
Expand All @@ -621,7 +621,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://user:pass@example.com/api/users',
'server.address': 'example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
});
});

Expand All @@ -635,7 +635,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://192.168.1.1:8080/api/users',
'server.address': '192.168.1.1',
'url.scheme': 'https:',
'url.scheme': 'https',
'url.port': '8080',
});
});
Expand All @@ -650,7 +650,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/api/users',
'url.full': 'https://[2001:db8::1]:8080/api/users',
'server.address': '[2001:db8::1]',
'url.scheme': 'https:',
'url.scheme': 'https',
'url.port': '8080',
});
});
Expand All @@ -665,7 +665,7 @@ describe('getHttpSpanDetailsFromUrlObject', () => {
'url.path': '/users',
'url.full': 'https://api.example.com/users',
'server.address': 'api.example.com',
'url.scheme': 'https:',
'url.scheme': 'https',
});
});
});
Expand Down
9 changes: 7 additions & 2 deletions packages/react-router/src/vite/makeCustomSentryVitePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
release,
} = options;

// Destructure keys that are merged explicitly below so the trailing spread
// cannot overwrite them with the user's raw value.
const { sourcemaps: userSourcemaps, ...restUnstableVitePluginOptions } =
unstable_sentryVitePluginOptions ?? {};

const sentryVitePlugins = sentryVitePlugin({
applicationKey,
authToken: authToken ?? process.env.SENTRY_AUTH_TOKEN,
Expand All @@ -45,9 +50,9 @@ export async function makeCustomSentryVitePlugins(options: SentryReactRouterBuil
// will be handled in buildEnd hook
sourcemaps: {
disable: true,
...unstable_sentryVitePluginOptions?.sourcemaps,
...userSourcemaps,
},
...unstable_sentryVitePluginOptions,
...restUnstableVitePluginOptions,
}) as Plugin[];

return sentryVitePlugins;
Expand Down
Loading