Skip to content

ref(core): Rename Span class to SentrySpan #10687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ The following previously deprecated API has been removed from the `@sentry/nextj
- `IS_BUILD`
- `isBuild`

## Removal of `Span` class export from SDK packages

In v8, we are no longer exporting the `Span` class from SDK packages (e.g. `@sentry/browser` or `@sentry/node`).
Internally, this class is now called `SentrySpan`, and it is no longer meant to be used by users directly.

## Removal of Severity Enum

In v7 we deprecated the `Severity` enum in favor of using the `SeverityLevel` type. In v8 we removed the `Severity`
Expand Down
3 changes: 1 addition & 2 deletions packages/browser/src/index.bundle.tracing.replay.feedback.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Feedback, feedbackIntegration } from '@sentry-internal/feedback';
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
import { Replay, replayIntegration } from '@sentry/replay';
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';

Expand Down Expand Up @@ -27,7 +27,6 @@ export {
// eslint-disable-next-line deprecation/deprecation
BrowserTracing,
browserTracingIntegration,
Span,
addExtensionMethods,
};
export * from './index.bundle.base';
3 changes: 1 addition & 2 deletions packages/browser/src/index.bundle.tracing.replay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Feedback, feedbackIntegration } from '@sentry-internal/integration-shims';
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
import { Replay, replayIntegration } from '@sentry/replay';
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';

Expand Down Expand Up @@ -27,7 +27,6 @@ export {
// eslint-disable-next-line deprecation/deprecation
BrowserTracing,
browserTracingIntegration,
Span,
addExtensionMethods,
};
export * from './index.bundle.base';
3 changes: 1 addition & 2 deletions packages/browser/src/index.bundle.tracing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This is exported so the loader does not fail when switching off Replay
import { Feedback, Replay, feedbackIntegration, replayIntegration } from '@sentry-internal/integration-shims';
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
import { BrowserTracing, addExtensionMethods } from '@sentry-internal/tracing';
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';

import * as Sentry from './index.bundle.base';
Expand All @@ -27,7 +27,6 @@ export {
// eslint-disable-next-line deprecation/deprecation
BrowserTracing,
browserTracingIntegration,
Span,
addExtensionMethods,
};
export * from './index.bundle.base';
8 changes: 4 additions & 4 deletions packages/core/src/tracing/idletransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { logger, timestampInSeconds } from '@sentry/utils';

import { DEBUG_BUILD } from '../debug-build';
import { spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';
import type { Span } from './span';
import { SpanRecorder } from './span';
import type { SentrySpan } from './sentrySpan';
import { SpanRecorder } from './sentrySpan';
import { Transaction } from './transaction';

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

// eslint-disable-next-line deprecation/deprecation
this.spanRecorder.spans = this.spanRecorder.spans.filter((span: Span) => {
this.spanRecorder.spans = this.spanRecorder.spans.filter((span: SentrySpan) => {
// If we are dealing with the transaction itself, we just return it
if (span.spanContext().spanId === this.spanContext().spanId) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { startIdleTransaction, addTracingExtensions } from './hubextensions';
export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction';
export type { BeforeFinishCallback } from './idletransaction';
export { Span } from './span';
export { SentrySpan } from './sentrySpan';
export { Transaction } from './transaction';
// eslint-disable-next-line deprecation/deprecation
export { getActiveTransaction } from './utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { setHttpStatus } from './spanstatus';
* @hidden
*/
export class SpanRecorder {
public spans: Span[];
public spans: SentrySpan[];

private readonly _maxlen: number;

Expand All @@ -52,7 +52,7 @@ export class SpanRecorder {
* trace tree (i.e.the first n spans with the smallest
* start_timestamp).
*/
public add(span: Span): void {
public add(span: SentrySpan): void {
if (this.spans.length > this._maxlen) {
// eslint-disable-next-line deprecation/deprecation
span.spanRecorder = undefined;
Expand All @@ -65,7 +65,7 @@ export class SpanRecorder {
/**
* Span contains all data about a span
*/
export class Span implements SpanInterface {
export class SentrySpan implements SpanInterface {
/**
* Tags for the span.
* @deprecated Use `spanToJSON(span).atttributes` instead.
Expand Down Expand Up @@ -386,7 +386,7 @@ export class Span implements SpanInterface {
public startChild(
spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>,
): SpanInterface {
const childSpan = new Span({
const childSpan = new SentrySpan({
...spanContext,
parentSpanId: this._spanId,
sampled: this._sampled,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/tracing/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary';
import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes';
import { spanTimeInputToSeconds, spanToJSON, spanToTraceContext } from '../utils/spanUtils';
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
import { Span as SpanClass, SpanRecorder } from './span';
import { SentrySpan, SpanRecorder } from './sentrySpan';
import { getCapturedScopesOnSpan } from './trace';

/** JSDoc */
export class Transaction extends SpanClass implements TransactionInterface {
export class Transaction extends SentrySpan implements TransactionInterface {
/**
* The reference to the current hub.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/utils/spanUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Span, SpanJSON, SpanTimeInput, TraceContext } from '@sentry/types';
import { dropUndefinedKeys, generateSentryTraceHeader, timestampInSeconds } from '@sentry/utils';
import type { Span as SpanClass } from '../tracing/span';
import type { SentrySpan } from '../tracing/sentrySpan';

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

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

/**
Expand Down
Loading