Skip to content
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
3 changes: 1 addition & 2 deletions packages/node/test/integration/breadcrumbs.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { addBreadcrumb, captureException, withIsolationScope, withScope } from '@sentry/core';
import { startSpan } from '@sentry/opentelemetry';
import { startSpan, addBreadcrumb, captureException, withIsolationScope, withScope } from '@sentry/core';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { getClient } from '../../src/';
import type { NodeClient } from '../../src/sdk/client';
Expand Down
3 changes: 1 addition & 2 deletions packages/node/test/integration/scope.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getCapturedScopesOnSpan, getCurrentScope } from '@sentry/core';
import { getClient } from '@sentry/opentelemetry';
import { getCapturedScopesOnSpan, getCurrentScope, getClient } from '@sentry/core';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import * as Sentry from '../../src/';
import type { NodeClient } from '../../src/sdk/client';
Expand Down
31 changes: 2 additions & 29 deletions packages/opentelemetry/src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
export { getRequestSpanData } from './utils/getRequestSpanData';

export { getScopesFromContext } from './utils/contextData';

export {
spanHasAttributes,
spanHasEvents,
spanHasKind,
spanHasName,
spanHasParentId,
spanHasStatus,
} from './utils/spanTypes';

// Re-export this for backwards compatibility (this used to be a different implementation)
export { getDynamicSamplingContextFromSpan } from '@sentry/core';

export { enhanceDscWithOpenTelemetryRootSpanName } from './utils/enhanceDscWithOpenTelemetryRootSpanName';

export { getActiveSpan } from './utils/getActiveSpan';
export {
startSpan,
startSpanManual,
startInactiveSpan,
withActiveSpan,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public API removals without deprecation

High Severity

Flagged because the PR Review Guidelines call out removal of publicly exported functions without deprecation as a critical breaking change. @sentry/opentelemetry drops public exports such as startSpan, getActiveSpan, getClient, continueTrace, shouldPropagateTraceForUrl, and the spanHas* helpers with no deprecation aliases and no MIGRATION.md note, so external importers can break on upgrade even if this repo no longer uses them.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 58b21e2. Configure here.

continueTrace,
getTraceContextForScope,
} from './trace';
export { getTraceContextForScope } from './trace';

export { suppressTracing } from './utils/suppressTracing';

Expand All @@ -33,7 +11,7 @@ export { setupEventContextTrace } from './setupEventContextTrace';
// eslint-disable-next-line typescript/no-deprecated
export { wrapContextManagerClass } from './contextManager';

export { SentryPropagator, shouldPropagateTraceForUrl } from './propagator';
export { SentryPropagator } from './propagator';
export { SentrySpanProcessor } from './spanProcessor';
export { SentrySampler, wrapSamplingDecision } from './sampler';
export { applyOtelSpanData } from './applyOtelSpanData';
Expand All @@ -44,8 +22,3 @@ export type { OpenTelemetryTracerProvider } from './types';
export { openTelemetrySetupCheck, setIsSetup } from './utils/setupCheck';

export { getSentryResource } from './resource';

export { withStreamedSpan } from '@sentry/core';

// Legacy
export { getClient } from '@sentry/core';
3 changes: 0 additions & 3 deletions packages/opentelemetry/src/propagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ export class SentryPropagator extends W3CBaggagePropagator {
}
}

// Re-exported from @sentry/core for backwards compatibility
export { shouldPropagateTraceForUrl } from '@sentry/core';

/**
* Get propagation injection data for the given context.
* The additional options can be passed to override the scope and client that is otherwise derived from the context.
Expand Down
39 changes: 2 additions & 37 deletions packages/opentelemetry/src/utils/spanTypes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { SpanKind, SpanStatus } from '@opentelemetry/api';
import type { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';
import type { SpanStatus } from '@opentelemetry/api';
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import type { AbstractSpan } from '../types';
import { isObjectLike } from '@sentry/core';
import { getParentSpanId } from './getParentSpanId';

/**
* Check if a given span has attributes.
Expand All @@ -16,16 +15,6 @@ export function spanHasAttributes<SpanType extends AbstractSpan>(
return isObjectLike(castSpan.attributes);
}

/**
* Check if a given span has a kind.
* This is necessary because the base `Span` type does not have a kind,
* so in places where we are passed a generic span, we need to check if we want to access it.
*/
export function spanHasKind<SpanType extends AbstractSpan>(span: SpanType): span is SpanType & { kind: SpanKind } {
const castSpan = span as ReadableSpan;
return typeof castSpan.kind === 'number';
}

/**
* Check if a given span has a status.
* This is necessary because the base `Span` type does not have a status,
Expand All @@ -47,27 +36,3 @@ export function spanHasName<SpanType extends AbstractSpan>(span: SpanType): span
const castSpan = span as ReadableSpan;
return !!castSpan.name;
}

/**
* Check if a given span has a kind.
* This is necessary because the base `Span` type does not have a kind,
* so in places where we are passed a generic span, we need to check if we want to access it.
*/
export function spanHasParentId<SpanType extends AbstractSpan>(
span: SpanType,
): span is SpanType & { parentSpanId: string } {
const castSpan = span as ReadableSpan;
return !!getParentSpanId(castSpan);
}

/**
* Check if a given span has events.
* This is necessary because the base `Span` type does not have events,
* so in places where we are passed a generic span, we need to check if we want to access it.
*/
export function spanHasEvents<SpanType extends AbstractSpan>(
span: SpanType,
): span is SpanType & { events: TimedEvent[] } {
const castSpan = span as ReadableSpan;
return Array.isArray(castSpan.events);
}
55 changes: 1 addition & 54 deletions packages/opentelemetry/test/utils/spanTypes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Span } from '@opentelemetry/api';
import { describe, expect, it } from 'vitest';
import { spanHasAttributes, spanHasEvents, spanHasKind, spanHasParentId } from '../../src/utils/spanTypes';
import { spanHasAttributes } from '../../src/utils/spanTypes';

describe('spanTypes', () => {
describe('spanHasAttributes', () => {
Expand All @@ -19,57 +19,4 @@ describe('spanTypes', () => {
}
});
});

describe('spanHasKind', () => {
it.each([
[{}, false],
[{ kind: null }, false],
[{ kind: 0 }, true],
[{ kind: 5 }, true],
[{ kind: 'TEST_KIND' }, false],
])('works with %j', (span, expected) => {
const castSpan = span as unknown as Span;
const actual = spanHasKind(castSpan);

expect(actual).toBe(expected);

if (actual) {
expect(castSpan.kind).toBeDefined();
}
});
});

describe('spanHasParentId', () => {
it.each([
[{}, false],
[{ parentSpanId: null }, false],
[{ parentSpanId: 'TEST_PARENT_ID' }, true],
])('works with %j', (span, expected) => {
const castSpan = span as unknown as Span;
const actual = spanHasParentId(castSpan);

expect(actual).toBe(expected);

if (actual) {
expect(castSpan.parentSpanId).toBeDefined();
}
});
});

describe('spanHasEvents', () => {
it.each([
[{}, false],
[{ events: null }, false],
[{ events: [] }, true],
])('works with %j', (span, expected) => {
const castSpan = span as unknown as Span;
const actual = spanHasEvents(castSpan);

expect(actual).toBe(expected);

if (actual) {
expect(castSpan.events).toBeDefined();
}
});
});
});
Loading