Skip to content

Commit dc5383d

Browse files
authored
ref(core): Rename Span class to SentrySpan (#10687)
And stop exporting it from packages other than core.
1 parent b38bccd commit dc5383d

File tree

29 files changed

+143
-158
lines changed

29 files changed

+143
-158
lines changed

MIGRATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ The following previously deprecated API has been removed from the `@sentry/nextj
5555
- `IS_BUILD`
5656
- `isBuild`
5757

58+
## Removal of `Span` class export from SDK packages
59+
60+
In v8, we are no longer exporting the `Span` class from SDK packages (e.g. `@sentry/browser` or `@sentry/node`).
61+
Internally, this class is now called `SentrySpan`, and it is no longer meant to be used by users directly.
62+
5863
## Removal of Severity Enum
5964

6065
In v7 we deprecated the `Severity` enum in favor of using the `SeverityLevel` type. In v8 we removed the `Severity`

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Feedback, feedbackIntegration } from '@sentry-internal/feedback';
2-
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
2+
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
33
import { Replay, replayIntegration } from '@sentry/replay';
44
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';
55

@@ -27,7 +27,6 @@ export {
2727
// eslint-disable-next-line deprecation/deprecation
2828
BrowserTracing,
2929
browserTracingIntegration,
30-
Span,
3130
addExtensionMethods,
3231
};
3332
export * from './index.bundle.base';

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Feedback, feedbackIntegration } from '@sentry-internal/integration-shims';
2-
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
2+
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
33
import { Replay, replayIntegration } from '@sentry/replay';
44
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';
55

@@ -27,7 +27,6 @@ export {
2727
// eslint-disable-next-line deprecation/deprecation
2828
BrowserTracing,
2929
browserTracingIntegration,
30-
Span,
3130
addExtensionMethods,
3231
};
3332
export * from './index.bundle.base';

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is exported so the loader does not fail when switching off Replay
22
import { Feedback, Replay, feedbackIntegration, replayIntegration } from '@sentry-internal/integration-shims';
3-
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
3+
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
44
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';
55

66
import * as Sentry from './index.bundle.base';
@@ -27,7 +27,6 @@ export {
2727
// eslint-disable-next-line deprecation/deprecation
2828
BrowserTracing,
2929
browserTracingIntegration,
30-
Span,
3130
addExtensionMethods,
3231
};
3332
export * from './index.bundle.base';

packages/core/src/tracing/idletransaction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { logger, timestampInSeconds } from '@sentry/utils';
44

55
import { DEBUG_BUILD } from '../debug-build';
66
import { spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';
7-
import type { Span } from './span';
8-
import { SpanRecorder } from './span';
7+
import type { SentrySpan } from './sentrySpan';
8+
import { SpanRecorder } from './sentrySpan';
99
import { Transaction } from './transaction';
1010

1111
export const TRACING_DEFAULTS = {
@@ -41,7 +41,7 @@ export class IdleTransactionSpanRecorder extends SpanRecorder {
4141
/**
4242
* @inheritDoc
4343
*/
44-
public add(span: Span): void {
44+
public add(span: SentrySpan): void {
4545
// We should make sure we do not push and pop activities for
4646
// the transaction that this span recorder belongs to.
4747
if (span.spanContext().spanId !== this.transactionSpanId) {
@@ -178,7 +178,7 @@ export class IdleTransaction extends Transaction {
178178
}
179179

180180
// eslint-disable-next-line deprecation/deprecation
181-
this.spanRecorder.spans = this.spanRecorder.spans.filter((span: Span) => {
181+
this.spanRecorder.spans = this.spanRecorder.spans.filter((span: SentrySpan) => {
182182
// If we are dealing with the transaction itself, we just return it
183183
if (span.spanContext().spanId === this.spanContext().spanId) {
184184
return true;

packages/core/src/tracing/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { startIdleTransaction, addTracingExtensions } from './hubextensions';
22
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction';
33
export type { BeforeFinishCallback } from './idletransaction';
4-
export { Span } from './span';
4+
export { SentrySpan } from './sentrySpan';
55
export { Transaction } from './transaction';
66
// eslint-disable-next-line deprecation/deprecation
77
export { getActiveTransaction } from './utils';

packages/core/src/tracing/span.ts renamed to packages/core/src/tracing/sentrySpan.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { setHttpStatus } from './spanstatus';
3737
* @hidden
3838
*/
3939
export class SpanRecorder {
40-
public spans: Span[];
40+
public spans: SentrySpan[];
4141

4242
private readonly _maxlen: number;
4343

@@ -52,7 +52,7 @@ export class SpanRecorder {
5252
* trace tree (i.e.the first n spans with the smallest
5353
* start_timestamp).
5454
*/
55-
public add(span: Span): void {
55+
public add(span: SentrySpan): void {
5656
if (this.spans.length > this._maxlen) {
5757
// eslint-disable-next-line deprecation/deprecation
5858
span.spanRecorder = undefined;
@@ -65,7 +65,7 @@ export class SpanRecorder {
6565
/**
6666
* Span contains all data about a span
6767
*/
68-
export class Span implements SpanInterface {
68+
export class SentrySpan implements SpanInterface {
6969
/**
7070
* Tags for the span.
7171
* @deprecated Use `spanToJSON(span).atttributes` instead.
@@ -386,7 +386,7 @@ export class Span implements SpanInterface {
386386
public startChild(
387387
spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>,
388388
): SpanInterface {
389-
const childSpan = new Span({
389+
const childSpan = new SentrySpan({
390390
...spanContext,
391391
parentSpanId: this._spanId,
392392
sampled: this._sampled,

packages/core/src/tracing/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary';
1919
import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes';
2020
import { spanTimeInputToSeconds, spanToJSON, spanToTraceContext } from '../utils/spanUtils';
2121
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
22-
import { Span as SpanClass, SpanRecorder } from './span';
22+
import { SentrySpan, SpanRecorder } from './sentrySpan';
2323
import { getCapturedScopesOnSpan } from './trace';
2424

2525
/** JSDoc */
26-
export class Transaction extends SpanClass implements TransactionInterface {
26+
export class Transaction extends SentrySpan implements TransactionInterface {
2727
/**
2828
* The reference to the current hub.
2929
*/

packages/core/src/utils/spanUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Span, SpanJSON, SpanTimeInput, TraceContext } from '@sentry/types';
22
import { dropUndefinedKeys, generateSentryTraceHeader, timestampInSeconds } from '@sentry/utils';
3-
import type { Span as SpanClass } from '../tracing/span';
3+
import type { SentrySpan } from '../tracing/sentrySpan';
44

55
// These are aligned with OpenTelemetry trace flags
66
export const TRACE_FLAG_NONE = 0x0;
@@ -72,7 +72,7 @@ function ensureTimestampInSeconds(timestamp: number): number {
7272
* TODO v8: When we remove the deprecated stuff from `span.ts`, we can remove the circular dependency again.
7373
*/
7474
export function spanToJSON(span: Span): Partial<SpanJSON> {
75-
if (spanIsSpanClass(span)) {
75+
if (spanIsSentrySpan(span)) {
7676
return span.getSpanJSON();
7777
}
7878

@@ -90,8 +90,8 @@ export function spanToJSON(span: Span): Partial<SpanJSON> {
9090
* Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.
9191
* :( So instead we approximate this by checking if it has the `getSpanJSON` method.
9292
*/
93-
function spanIsSpanClass(span: Span): span is SpanClass {
94-
return typeof (span as SpanClass).getSpanJSON === 'function';
93+
function spanIsSentrySpan(span: Span): span is SentrySpan {
94+
return typeof (span as SentrySpan).getSpanJSON === 'function';
9595
}
9696

9797
/**

0 commit comments

Comments
 (0)