diff --git a/packages/bun/src/integrations/bunserver.ts b/packages/bun/src/integrations/bunserver.ts index 5075d2f8f250..f5b6a52d3dd0 100644 --- a/packages/bun/src/integrations/bunserver.ts +++ b/packages/bun/src/integrations/bunserver.ts @@ -11,7 +11,7 @@ import { startSpan, withIsolationScope, } from '@sentry/core'; -import type { IntegrationFn } from '@sentry/types'; +import type { IntegrationFn, SpanAttributes } from '@sentry/types'; import { getSanitizedUrlString, parseUrl } from '@sentry/utils'; const INTEGRATION_NAME = 'BunServer'; @@ -53,7 +53,7 @@ export function instrumentBunServe(): void { function instrumentBunServeOptions(serveOptions: Parameters[0]): void { serveOptions.fetch = new Proxy(serveOptions.fetch, { apply(fetchTarget, fetchThisArg, fetchArgs: Parameters) { - return withIsolationScope(() => { + return withIsolationScope(isolationScope => { const request = fetchArgs[0]; const upperCaseMethod = request.method.toUpperCase(); if (upperCaseMethod === 'OPTIONS' || upperCaseMethod === 'HEAD') { @@ -61,37 +61,34 @@ function instrumentBunServeOptions(serveOptions: Parameters[0] } const parsedUrl = parseUrl(request.url); - const data: Record = { + const attributes: SpanAttributes = { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.bun.serve', 'http.request.method': request.method || 'GET', [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url', }; if (parsedUrl.search) { - data['http.query'] = parsedUrl.search; + attributes['http.query'] = parsedUrl.search; } const url = getSanitizedUrlString(parsedUrl); + isolationScope.setSDKProcessingMetadata({ + request: { + url, + method: request.method, + headers: request.headers.toJSON(), + }, + }); + return continueTrace( { sentryTrace: request.headers.get('sentry-trace') || '', baggage: request.headers.get('baggage') }, ctx => { return startSpan( { - attributes: { - [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.bun.serve', - }, + attributes, op: 'http.server', name: `${request.method} ${parsedUrl.path || '/'}`, ...ctx, - data, - metadata: { - // eslint-disable-next-line deprecation/deprecation - ...ctx.metadata, - request: { - url, - method: request.method, - headers: request.headers.toJSON(), - }, - }, }, async span => { try { diff --git a/packages/react/src/profiler.tsx b/packages/react/src/profiler.tsx index 54ed3fa541c8..5008ffdc0010 100644 --- a/packages/react/src/profiler.tsx +++ b/packages/react/src/profiler.tsx @@ -1,5 +1,5 @@ import { startInactiveSpan } from '@sentry/browser'; -import { spanToJSON, withActiveSpan } from '@sentry/core'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON, withActiveSpan } from '@sentry/core'; import type { Span } from '@sentry/types'; import { timestampInSeconds } from '@sentry/utils'; import hoistNonReactStatics from 'hoist-non-react-statics'; @@ -59,8 +59,10 @@ class Profiler extends React.Component { name: `<${name}>`, onlyIfParent: true, op: REACT_MOUNT_OP, - origin: 'auto.ui.react.profiler', - attributes: { 'ui.component_name': name }, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler', + 'ui.component_name': name, + }, }); } @@ -86,9 +88,9 @@ class Profiler extends React.Component { name: `<${this.props.name}>`, onlyIfParent: true, op: REACT_UPDATE_OP, - origin: 'auto.ui.react.profiler', - startTimestamp: now, + startTime: now, attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler', 'ui.component_name': this.props.name, 'ui.react.changed_props': changedProps, }, @@ -114,15 +116,17 @@ class Profiler extends React.Component { const { name, includeRender = true } = this.props; if (this._mountSpan && includeRender) { - const startTimestamp = spanToJSON(this._mountSpan).timestamp; + const startTime = spanToJSON(this._mountSpan).timestamp; withActiveSpan(this._mountSpan, () => { const renderSpan = startInactiveSpan({ onlyIfParent: true, name: `<${name}>`, op: REACT_RENDER_OP, - origin: 'auto.ui.react.profiler', - startTimestamp, - attributes: { 'ui.component_name': name }, + startTime, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler', + 'ui.component_name': name, + }, }); if (renderSpan) { // Have to cast to Span because the type of _mountSpan is Span | undefined @@ -192,8 +196,10 @@ function useProfiler( name: `<${name}>`, onlyIfParent: true, op: REACT_MOUNT_OP, - origin: 'auto.ui.react.profiler', - attributes: { 'ui.component_name': name }, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler', + 'ui.component_name': name, + }, }); }); @@ -204,16 +210,18 @@ function useProfiler( return (): void => { if (mountSpan && options.hasRenderSpan) { - const startTimestamp = spanToJSON(mountSpan).timestamp; + const startTime = spanToJSON(mountSpan).timestamp; const endTimestamp = timestampInSeconds(); const renderSpan = startInactiveSpan({ name: `<${name}>`, onlyIfParent: true, op: REACT_RENDER_OP, - origin: 'auto.ui.react.profiler', - startTimestamp, - attributes: { 'ui.component_name': name }, + startTime, + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.react.profiler', + 'ui.component_name': name, + }, }); if (renderSpan) { // Have to cast to Span because the type of _mountSpan is Span | undefined diff --git a/packages/react/test/profiler.test.tsx b/packages/react/test/profiler.test.tsx index de770b362473..9f8b23063e00 100644 --- a/packages/react/test/profiler.test.tsx +++ b/packages/react/test/profiler.test.tsx @@ -74,8 +74,10 @@ describe('withProfiler', () => { name: `<${UNKNOWN_COMPONENT}>`, onlyIfParent: true, op: REACT_MOUNT_OP, - origin: 'auto.ui.react.profiler', - attributes: { 'ui.component_name': 'unknown' }, + attributes: { + 'sentry.origin': 'auto.ui.react.profiler', + 'ui.component_name': 'unknown', + }, }); }); }); @@ -93,9 +95,11 @@ describe('withProfiler', () => { name: `<${UNKNOWN_COMPONENT}>`, onlyIfParent: true, op: REACT_RENDER_OP, - origin: 'auto.ui.react.profiler', - startTimestamp: undefined, - attributes: { 'ui.component_name': 'unknown' }, + startTime: undefined, + attributes: { + 'sentry.origin': 'auto.ui.react.profiler', + 'ui.component_name': 'unknown', + }, }); expect(mockFinish).toHaveBeenCalledTimes(2); }); @@ -123,24 +127,30 @@ describe('withProfiler', () => { rerender(); expect(mockStartInactiveSpan).toHaveBeenCalledTimes(2); expect(mockStartInactiveSpan).toHaveBeenLastCalledWith({ - attributes: { 'ui.react.changed_props': ['num'], 'ui.component_name': 'unknown' }, + attributes: { + 'sentry.origin': 'auto.ui.react.profiler', + 'ui.react.changed_props': ['num'], + 'ui.component_name': 'unknown', + }, name: `<${UNKNOWN_COMPONENT}>`, onlyIfParent: true, op: REACT_UPDATE_OP, - origin: 'auto.ui.react.profiler', - startTimestamp: expect.any(Number), + startTime: expect.any(Number), }); expect(mockFinish).toHaveBeenCalledTimes(2); // New props yet again rerender(); expect(mockStartInactiveSpan).toHaveBeenCalledTimes(3); expect(mockStartInactiveSpan).toHaveBeenLastCalledWith({ - attributes: { 'ui.react.changed_props': ['num'], 'ui.component_name': 'unknown' }, + attributes: { + 'sentry.origin': 'auto.ui.react.profiler', + 'ui.react.changed_props': ['num'], + 'ui.component_name': 'unknown', + }, name: `<${UNKNOWN_COMPONENT}>`, onlyIfParent: true, op: REACT_UPDATE_OP, - origin: 'auto.ui.react.profiler', - startTimestamp: expect.any(Number), + startTime: expect.any(Number), }); expect(mockFinish).toHaveBeenCalledTimes(3); @@ -179,8 +189,10 @@ describe('useProfiler()', () => { name: '', onlyIfParent: true, op: REACT_MOUNT_OP, - origin: 'auto.ui.react.profiler', - attributes: { 'ui.component_name': 'Example' }, + attributes: { + 'ui.component_name': 'Example', + 'sentry.origin': 'auto.ui.react.profiler', + }, }); }); }); @@ -204,8 +216,10 @@ describe('useProfiler()', () => { name: '', onlyIfParent: true, op: REACT_RENDER_OP, - origin: 'auto.ui.react.profiler', - attributes: { 'ui.component_name': 'Example' }, + attributes: { + 'sentry.origin': 'auto.ui.react.profiler', + 'ui.component_name': 'Example', + }, }), ); }); diff --git a/packages/remix/src/client/performance.tsx b/packages/remix/src/client/performance.tsx index 1c2c83f6f052..fd997544bb8b 100644 --- a/packages/remix/src/client/performance.tsx +++ b/packages/remix/src/client/performance.tsx @@ -1,4 +1,9 @@ -import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getRootSpan } from '@sentry/core'; +import { + SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, + SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, + getActiveSpan, + getRootSpan, +} from '@sentry/core'; import type { browserTracingIntegration as originalBrowserTracingIntegration } from '@sentry/react'; import type { BrowserClient, ErrorBoundaryProps } from '@sentry/react'; import { @@ -72,8 +77,8 @@ export function startPageloadSpan(): void { const spanContext: StartSpanOptions = { name: initPathName, op: 'pageload', - origin: 'auto.pageload.remix', attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.remix', [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url', }, }; @@ -96,8 +101,8 @@ function startNavigationSpan(matches: RouteMatch[]): void { const spanContext: StartSpanOptions = { name: matches[matches.length - 1].id, op: 'navigation', - origin: 'auto.navigation.remix', attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.remix', [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', }, }; diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index fa0b7d514358..9c0877045084 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -1,4 +1,5 @@ import type { IdleTransaction } from '@sentry/core'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core'; import { getActiveSpan } from '@sentry/core'; import { getCurrentHub } from '@sentry/core'; import { @@ -232,7 +233,7 @@ export const browserTracingIntegration = ((_options: Partial next(params), ); diff --git a/packages/vue/src/tracing.ts b/packages/vue/src/tracing.ts index 277acc959c3f..70f662559adf 100644 --- a/packages/vue/src/tracing.ts +++ b/packages/vue/src/tracing.ts @@ -1,4 +1,4 @@ -import { getActiveSpan, startInactiveSpan } from '@sentry/browser'; +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan, startInactiveSpan } from '@sentry/browser'; import type { Span } from '@sentry/types'; import { logger, timestampInSeconds } from '@sentry/utils'; @@ -75,7 +75,9 @@ export const createTracingMixins = (options: TracingOptions): Mixins => { startInactiveSpan({ name: 'Application Render', op: `${VUE_OP}.render`, - origin: 'auto.ui.vue', + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.vue', + }, }); } } @@ -109,7 +111,9 @@ export const createTracingMixins = (options: TracingOptions): Mixins => { this.$_sentrySpans[operation] = startInactiveSpan({ name: `Vue <${name}>`, op: `${VUE_OP}.${operation}`, - origin: 'auto.ui.vue', + attributes: { + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.vue', + }, }); } } else {