Skip to content

Commit 496b432

Browse files
committed
feat: Ensure getRootSpan() does not rely on transaction
Instead, we keep the root span as a non-enumerable property on the span.
1 parent 8b775cb commit 496b432

File tree

34 files changed

+170
-145
lines changed

34 files changed

+170
-145
lines changed

packages/angular/src/tracing.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ export class TraceService implements OnDestroy {
289289
}
290290

291291
const rootSpan = getRootSpan(activeSpan);
292-
if (!rootSpan) {
293-
this._pageloadOngoing = false;
294-
return false;
295-
}
296292

297293
this._pageloadOngoing = spanToJSON(rootSpan).op === 'pageload';
298294
return this._pageloadOngoing;

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export {
5959
linkedErrorsIntegration,
6060
setMeasurement,
6161
getActiveSpan,
62+
getRootSpan,
6263
startSpan,
6364
startInactiveSpan,
6465
startSpanManual,

packages/astro/src/index.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export declare const startSpan: typeof clientSdk.startSpan;
3232
export declare const startInactiveSpan: typeof clientSdk.startInactiveSpan;
3333
export declare const startSpanManual: typeof clientSdk.startSpanManual;
3434
export declare const withActiveSpan: typeof clientSdk.withActiveSpan;
35+
export declare const getRootSpan: typeof clientSdk.getRootSpan;
3536
export declare const Span: clientSdk.Span;
3637

3738
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ addTracingExtensions();
88

99
export {
1010
getActiveSpan,
11+
getRootSpan,
1112
startSpan,
1213
startInactiveSpan,
1314
startSpanManual,

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ addTracingExtensions();
88

99
export {
1010
getActiveSpan,
11+
getRootSpan,
1112
startSpan,
1213
startInactiveSpan,
1314
startSpanManual,

packages/browser/src/index.bundle.tracing.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ addTracingExtensions();
88

99
export {
1010
getActiveSpan,
11+
getRootSpan,
1112
startSpan,
1213
startInactiveSpan,
1314
startSpanManual,

packages/browser/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export type { RequestInstrumentationOptions } from '@sentry-internal/tracing';
6363
export {
6464
addTracingExtensions,
6565
getActiveSpan,
66+
getRootSpan,
6667
startSpan,
6768
startInactiveSpan,
6869
startSpanManual,

packages/bun/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export {
6464
withMonitor,
6565
setMeasurement,
6666
getActiveSpan,
67+
getRootSpan,
6768
startSpan,
6869
startInactiveSpan,
6970
startSpanManual,

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export {
9191
spanIsSampled,
9292
spanToTraceContext,
9393
getSpanDescendants,
94+
getRootSpan,
9495
} from './utils/spanUtils';
95-
export { getRootSpan } from './utils/getRootSpan';
9696
export { applySdkMetadata } from './utils/sdkMetadata';
9797
export { DEFAULT_ENVIRONMENT } from './constants';
9898
/* eslint-disable deprecation/deprecation */

packages/core/src/server-runtime-client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import {
2424
getDynamicSamplingContextFromClient,
2525
getDynamicSamplingContextFromSpan,
2626
} from './tracing';
27-
import { getRootSpan } from './utils/getRootSpan';
28-
import { spanToTraceContext } from './utils/spanUtils';
27+
import { getRootSpan, spanToTraceContext } from './utils/spanUtils';
2928

3029
export interface ServerRuntimeClientOptions extends ClientOptions<BaseTransportOptions> {
3130
platform?: string;
@@ -256,8 +255,9 @@ export class ServerRuntimeClient<
256255
// eslint-disable-next-line deprecation/deprecation
257256
const span = scope.getSpan();
258257
if (span) {
259-
const samplingContext = getRootSpan(span) ? getDynamicSamplingContextFromSpan(span) : undefined;
260-
return [samplingContext, spanToTraceContext(span)];
258+
const rootSpan = getRootSpan(span);
259+
const samplingContext = getDynamicSamplingContextFromSpan(rootSpan);
260+
return [samplingContext, spanToTraceContext(rootSpan)];
261261
}
262262

263263
const { traceId, spanId, parentSpanId, dsc } = scope.getPropagationContext();

0 commit comments

Comments
 (0)