Skip to content

Commit f8c1637

Browse files
authored
feat(v8): Remove deprecated trace and startActiveSpan methods (#10593)
ref #10100
1 parent b5ec424 commit f8c1637

File tree

14 files changed

+7
-92
lines changed

14 files changed

+7
-92
lines changed

dev-packages/e2e-tests/test-applications/nextjs-app-dir/pages/api/async-context-edge-endpoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ export const config = {
55
};
66

77
export default async function handler() {
8-
// Without `runWithAsyncContext` and a working async context strategy the two spans created by `Sentry.trace()` would be nested.
8+
// Without `runWithAsyncContext` and a working async context strategy the two spans created by `Sentry.startSpan()` would be nested.
99

1010
const outerSpanPromise = Sentry.runWithAsyncContext(() => {
11-
return Sentry.trace({ name: 'outer-span' }, () => {
11+
return Sentry.startSpan({ name: 'outer-span' }, () => {
1212
return new Promise<void>(resolve => setTimeout(resolve, 300));
1313
});
1414
});
1515

1616
setTimeout(() => {
1717
Sentry.runWithAsyncContext(() => {
18-
return Sentry.trace({ name: 'inner-span' }, () => {
18+
return Sentry.startSpan({ name: 'inner-span' }, () => {
1919
return new Promise<void>(resolve => setTimeout(resolve, 100));
2020
});
2121
});

dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ const NODE_EXPORTS_IGNORE = [
1111
'default',
1212
// Probably generated by transpilation, no need to require it
1313
'__esModule',
14-
// this function was deprecated almost immediately after it was introduced
15-
// due to a name change (startSpan). No need to re-export it IMHO.
16-
'startActiveSpan',
17-
// this was never meant for external use (and documented as such)
18-
'trace',
1914
// These Node exports were only made for type definition fixes (see #10339)
2015
'Undici',
2116
'Http',

packages/browser/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export {
7474
getActiveTransaction,
7575
getSpanStatusFromHttpCode,
7676
setHttpStatus,
77-
// eslint-disable-next-line deprecation/deprecation
78-
trace,
7977
makeMultiplexedTransport,
8078
// eslint-disable-next-line deprecation/deprecation
8179
ModuleMetadata,

packages/bun/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export {
6262
setUser,
6363
getSpanStatusFromHttpCode,
6464
setHttpStatus,
65-
// eslint-disable-next-line deprecation/deprecation
66-
trace,
6765
withScope,
6866
withIsolationScope,
6967
captureCheckIn,

packages/core/src/tracing/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ export {
1313
} from './spanstatus';
1414
export type { SpanStatusType } from './spanstatus';
1515
export {
16-
// eslint-disable-next-line deprecation/deprecation
17-
trace,
1816
getActiveSpan,
1917
startSpan,
2018
startInactiveSpan,
21-
// eslint-disable-next-line deprecation/deprecation
22-
startActiveSpan,
2319
startSpanManual,
2420
continueTrace,
2521
} from './trace';

packages/core/src/tracing/trace.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,6 @@ import { handleCallbackErrors } from '../utils/handleCallbackErrors';
1212
import { hasTracingEnabled } from '../utils/hasTracingEnabled';
1313
import { spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';
1414

15-
/**
16-
* Wraps a function with a transaction/span and finishes the span after the function is done.
17-
*
18-
* Note that if you have not enabled tracing extensions via `addTracingExtensions`
19-
* or you didn't set `tracesSampleRate`, this function will not generate spans
20-
* and the `span` returned from the callback will be undefined.
21-
*
22-
* This function is meant to be used internally and may break at any time. Use at your own risk.
23-
*
24-
* @internal
25-
* @private
26-
*
27-
* @deprecated Use `startSpan` instead.
28-
*/
29-
export function trace<T>(
30-
context: TransactionContext,
31-
callback: (span?: Span) => T,
32-
// eslint-disable-next-line @typescript-eslint/no-empty-function
33-
onError: (error: unknown, span?: Span) => void = () => {},
34-
// eslint-disable-next-line @typescript-eslint/no-empty-function
35-
afterFinish: () => void = () => {},
36-
): T {
37-
// eslint-disable-next-line deprecation/deprecation
38-
const hub = getCurrentHub();
39-
const scope = getCurrentScope();
40-
// eslint-disable-next-line deprecation/deprecation
41-
const parentSpan = scope.getSpan();
42-
43-
const ctx = normalizeContext(context);
44-
const activeSpan = createChildSpanOrTransaction(hub, parentSpan, ctx);
45-
46-
// eslint-disable-next-line deprecation/deprecation
47-
scope.setSpan(activeSpan);
48-
49-
return handleCallbackErrors(
50-
() => callback(activeSpan),
51-
error => {
52-
activeSpan && activeSpan.setStatus('internal_error');
53-
onError(error, activeSpan);
54-
},
55-
() => {
56-
activeSpan && activeSpan.end();
57-
// eslint-disable-next-line deprecation/deprecation
58-
scope.setSpan(parentSpan);
59-
afterFinish();
60-
},
61-
);
62-
}
63-
6415
/**
6516
* Wraps a function with a transaction/span and finishes the span after the function is done.
6617
* The created span is the active span and will be used as parent by other spans created inside the function
@@ -105,11 +56,6 @@ export function startSpan<T>(context: StartSpanOptions, callback: (span: Span |
10556
});
10657
}
10758

108-
/**
109-
* @deprecated Use {@link startSpan} instead.
110-
*/
111-
export const startActiveSpan = startSpan;
112-
11359
/**
11460
* Similar to `Sentry.startSpan`. Wraps a function with a transaction/span, but does not finish the span
11561
* after the function is done automatically. You'll have to call `span.end()` manually.

packages/deno/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export {
6161
setUser,
6262
getSpanStatusFromHttpCode,
6363
setHttpStatus,
64-
// eslint-disable-next-line deprecation/deprecation
65-
trace,
6664
withScope,
6765
withIsolationScope,
6866
captureCheckIn,

packages/node-experimental/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ You can manual instrument using the following APIs:
5959
```js
6060
const Sentry = require('@sentry/node-experimental');
6161

62-
Sentry.startActiveSpan({ description: 'outer' }, function (span) {
62+
Sentry.startSpan({ description: 'outer' }, function (span) {
6363
span.setData(customData);
6464
doSomethingSlow();
65-
Sentry.startActiveSpan({ description: 'inner' }, function() {
65+
Sentry.startSpan({ description: 'inner' }, function() {
6666
// inner span is a child of outer span
6767
doSomethingVerySlow();
6868
// inner span is auto-ended when this callback ends
@@ -72,13 +72,13 @@ Sentry.startActiveSpan({ description: 'outer' }, function (span) {
7272
```
7373

7474
You can also create spans without marking them as the active span.
75-
Note that for most scenarios, we recommend the `startActiveSpan` syntax.
75+
Note that for most scenarios, we recommend the `startSpan` syntax.
7676

7777
```js
7878
const Sentry = require('@sentry/node-experimental');
7979

8080
// This will _not_ be put on the scope/set as active, so no other spans will be attached to it
81-
const span = Sentry.startSpan({ description: 'non-active span' });
81+
const span = Sentry.startInactiveSpan({ description: 'non-active span' });
8282

8383
doSomethingSlow();
8484

packages/node-experimental/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export {
7474
SDK_VERSION,
7575
getSpanStatusFromHttpCode,
7676
setHttpStatus,
77-
// eslint-disable-next-line deprecation/deprecation
78-
trace,
7977
captureCheckIn,
8078
withMonitor,
8179
hapiErrorPlugin,

packages/node/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ export {
6161
setUser,
6262
getSpanStatusFromHttpCode,
6363
setHttpStatus,
64-
// eslint-disable-next-line deprecation/deprecation
65-
trace,
6664
withScope,
6765
withIsolationScope,
6866
captureCheckIn,
6967
withMonitor,
7068
setMeasurement,
7169
getActiveSpan,
7270
startSpan,
73-
// eslint-disable-next-line deprecation/deprecation
74-
startActiveSpan,
7571
startInactiveSpan,
7672
startSpanManual,
7773
continueTrace,

packages/remix/src/index.server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ export {
5050
setUser,
5151
getSpanStatusFromHttpCode,
5252
setHttpStatus,
53-
// eslint-disable-next-line deprecation/deprecation
54-
trace,
5553
withScope,
5654
withIsolationScope,
5755
autoDiscoverNodePerformanceMonitoringIntegrations,

packages/serverless/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export {
7070
setMeasurement,
7171
getActiveSpan,
7272
startSpan,
73-
// eslint-disable-next-line deprecation/deprecation
74-
startActiveSpan,
7573
startInactiveSpan,
7674
startSpanManual,
7775
continueTrace,

packages/sveltekit/src/server/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export {
4444
setUser,
4545
getSpanStatusFromHttpCode,
4646
setHttpStatus,
47-
// eslint-disable-next-line deprecation/deprecation
48-
trace,
4947
withScope,
5048
withIsolationScope,
5149
autoDiscoverNodePerformanceMonitoringIntegrations,
@@ -76,8 +74,6 @@ export {
7674
setMeasurement,
7775
getActiveSpan,
7876
startSpan,
79-
// eslint-disable-next-line deprecation/deprecation
80-
startActiveSpan,
8177
startInactiveSpan,
8278
startSpanManual,
8379
continueTrace,

packages/vercel-edge/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export {
6161
setUser,
6262
getSpanStatusFromHttpCode,
6363
setHttpStatus,
64-
// eslint-disable-next-line deprecation/deprecation
65-
trace,
6664
withScope,
6765
withIsolationScope,
6866
captureCheckIn,

0 commit comments

Comments
 (0)