Skip to content

Commit e7b7d08

Browse files
author
Luca Forstner
authored
feat!: Remove enableTracing (#15078)
1 parent fc48f83 commit e7b7d08

File tree

21 files changed

+53
-81
lines changed

21 files changed

+53
-81
lines changed

docs/migration/v8-to-v9.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ The following outlines deprecations that were introduced in version 8 of the SDK
326326

327327
- **Passing `undefined` to `tracesSampleRate` / `tracesSampler` / `enableTracing` will be handled differently in v9**
328328

329-
In v8, explicitly setting `tracesSampleRate` (even if it is set to `undefined`) will result in tracing being _enabled_, although no spans will be generated.
329+
In v8, explicitly setting `tracesSampleRate` (even if it is set to `undefined`) resulted in tracing being _enabled_, although no spans were generated.
330330

331331
```ts
332332
Sentry.init({
@@ -338,6 +338,8 @@ In v9, we will streamline this behavior so that passing `undefined` will result
338338

339339
If you are relying on `undefined` being passed in and having tracing enabled because of this, you should update your config to set e.g. `tracesSampleRate: 0` instead, which will also enable tracing in v9.
340340

341+
The `enableTracing` option was removed. In v9, to emulate `enableTracing: true`, set `tracesSampleRate: 1`. To emulate `enableTracing: false`, remove the `tracesSampleRate` and `tracesSampler` options (if configured).
342+
341343
- **The `autoSessionTracking` option is deprecated.**
342344

343345
To enable session tracking, it is recommended to unset `autoSessionTracking` and ensure that either, in browser environments the `browserSessionIntegration` is added, or in server environments the `httpIntegration` is added.

packages/astro/test/client/sdk.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('Sentry client SDK', () => {
5252
it.each([
5353
['tracesSampleRate', { tracesSampleRate: 0 }],
5454
['tracesSampler', { tracesSampler: () => 1.0 }],
55-
['enableTracing', { enableTracing: true }],
5655
['no tracing option set', {}],
5756
])('adds browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => {
5857
init({
@@ -72,7 +71,7 @@ describe('Sentry client SDK', () => {
7271

7372
init({
7473
dsn: 'https://public@dsn.ingest.sentry.io/1337',
75-
enableTracing: true,
74+
tracesSampleRate: 1,
7675
});
7776

7877
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations || [];
@@ -90,7 +89,7 @@ describe('Sentry client SDK', () => {
9089
integrations: [
9190
browserTracingIntegration({ finalTimeout: 10, instrumentNavigation: false, instrumentPageLoad: false }),
9291
],
93-
enableTracing: true,
92+
tracesSampleRate: 1,
9493
});
9594

9695
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');

packages/cloudflare/test/integrations/fetch.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ describe('WinterCGFetch instrumentation', () => {
2626

2727
client = new FakeClient({
2828
dsn: 'https://public@dsn.ingest.sentry.io/1337',
29-
enableTracing: true,
3029
tracesSampleRate: 1,
3130
integrations: [],
3231
transport: () => ({

packages/core/src/tracing/sampling.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { parseSampleRate } from '../utils/parseSampleRate';
1212
* sent to Sentry.
1313
*/
1414
export function sampleSpan(
15-
options: Pick<Options, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'>,
15+
options: Pick<Options, 'tracesSampleRate' | 'tracesSampler'>,
1616
samplingContext: SamplingContext,
1717
sampleRand: number,
1818
): [sampled: boolean, sampleRate?: number] {
@@ -21,7 +21,7 @@ export function sampleSpan(
2121
return [false];
2222
}
2323

24-
// we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` nor `enableTracing` were defined, so one of these should
24+
// we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` were defined, so one of these should
2525
// work; prefer the hook if so
2626
let sampleRate;
2727
if (typeof options.tracesSampler === 'function') {
@@ -30,9 +30,6 @@ export function sampleSpan(
3030
sampleRate = samplingContext.parentSampled;
3131
} else if (typeof options.tracesSampleRate !== 'undefined') {
3232
sampleRate = options.tracesSampleRate;
33-
} else {
34-
// When `enableTracing === true`, we use a sample rate of 100%
35-
sampleRate = 1;
3633
}
3734

3835
// Since this is coming from the user (or from a function provided by the user), who knows what we might get.

packages/core/src/types-hoist/options.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
8181
*/
8282
tracesSampleRate?: number;
8383

84-
/**
85-
* If this is enabled, spans and trace data will be generated and captured.
86-
* This will set the `tracesSampleRate` to the recommended default of `1.0` if `tracesSampleRate` is undefined.
87-
* Note that `tracesSampleRate` and `tracesSampler` take precedence over this option.
88-
*
89-
* @deprecated This option is deprecated and will be removed in the next major version. If you want to enable performance
90-
* monitoring, please use the `tracesSampleRate` or `tracesSampler` options instead. If you wan't to disable performance
91-
* monitoring, remove the `tracesSampler` and `tracesSampleRate` options.
92-
*/
93-
enableTracing?: boolean;
94-
9584
/**
9685
* If this is enabled, any spans started will always have their parent be the active root span,
9786
* if there is any active span.

packages/core/src/utils/hasTracingEnabled.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ declare const __SENTRY_TRACING__: boolean | undefined;
1010
* Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
1111
*/
1212
export function hasTracingEnabled(
13-
maybeOptions?: Pick<Options, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'> | undefined,
13+
maybeOptions?: Pick<Options, 'tracesSampleRate' | 'tracesSampler'> | undefined,
1414
): boolean {
1515
if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {
1616
return false;
1717
}
1818

1919
const client = getClient();
2020
const options = maybeOptions || client?.getOptions();
21-
// eslint-disable-next-line deprecation/deprecation
22-
return !!options && (options.enableTracing || options.tracesSampleRate != null || !!options.tracesSampler);
21+
return (
22+
!!options &&
23+
// Note: This check is `!= null`, meaning "nullish"
24+
(options.tracesSampleRate != null || !!options.tracesSampler)
25+
);
2326
}

packages/core/test/lib/feedback.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ describe('captureFeedback', () => {
314314
getDefaultTestClientOptions({
315315
dsn: 'https://dsn@ingest.f00.f00/1',
316316
enableSend: true,
317-
enableTracing: true,
317+
tracesSampleRate: 1,
318318
// We don't care about transactions here...
319319
beforeSendTransaction() {
320320
return null;
@@ -385,7 +385,7 @@ describe('captureFeedback', () => {
385385
getDefaultTestClientOptions({
386386
dsn: 'https://dsn@ingest.f00.f00/1',
387387
enableSend: true,
388-
enableTracing: true,
388+
tracesSampleRate: 1,
389389
// We don't care about transactions here...
390390
beforeSendTransaction() {
391391
return null;

packages/core/test/lib/tracing/errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('registerErrorHandlers()', () => {
2424
beforeEach(() => {
2525
mockAddGlobalErrorInstrumentationHandler.mockClear();
2626
mockAddGlobalUnhandledRejectionInstrumentationHandler.mockClear();
27-
const options = getDefaultTestClientOptions({ enableTracing: true });
27+
const options = getDefaultTestClientOptions({ tracesSampleRate: 1 });
2828
const client = new TestClient(options);
2929
setCurrentClient(client);
3030
client.init();

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ describe('withActiveSpan()', () => {
16841684

16851685
setAsyncContextStrategy(undefined);
16861686

1687-
const options = getDefaultTestClientOptions({ enableTracing: true });
1687+
const options = getDefaultTestClientOptions({ tracesSampleRate: 1 });
16881688
const client = new TestClient(options);
16891689
setCurrentClient(client);
16901690
client.init();

packages/core/test/lib/utils/hasTracingEnabled.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,13 @@ describe('hasTracingEnabled', () => {
55
const tracesSampleRate = 1;
66
it.each([
77
['No options', undefined, false],
8-
['No tracesSampler or tracesSampleRate or enableTracing', {}, false],
8+
['No tracesSampler or tracesSampleRate', {}, false],
99
['With tracesSampler', { tracesSampler }, true],
1010
['With tracesSampleRate', { tracesSampleRate }, true],
11-
['With enableTracing=true', { enableTracing: true }, true],
12-
['With enableTracing=false', { enableTracing: false }, false],
13-
['With enableTracing=undefined', { enableTracing: undefined }, false],
1411
['With tracesSampleRate=undefined', { tracesSampleRate: undefined }, false],
1512
['With tracesSampleRate=0', { tracesSampleRate: 0 }, true],
1613
['With tracesSampler=undefined', { tracesSampler: undefined }, false],
17-
['With tracesSampler && enableTracing=false', { tracesSampler, enableTracing: false }, true],
18-
['With tracesSampleRate && enableTracing=false', { tracesSampler, enableTracing: false }, true],
1914
['With tracesSampler and tracesSampleRate', { tracesSampler, tracesSampleRate }, true],
20-
[
21-
'With tracesSampler and tracesSampleRate and enableTracing=true',
22-
{ tracesSampler, tracesSampleRate, enableTracing: true },
23-
true,
24-
],
25-
[
26-
'With tracesSampler and tracesSampleRate and enableTracing=false',
27-
{ tracesSampler, tracesSampleRate, enableTracing: false },
28-
true,
29-
],
3015
])(
3116
'%s',
3217
(_: string, input: Parameters<typeof hasTracingEnabled>[0], output: ReturnType<typeof hasTracingEnabled>) => {

0 commit comments

Comments
 (0)