diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3004ccb6..338e29b41d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Remove deprecated `beforeScreenshot` ([#2662](https://github.com/getsentry/sentry-dart/pull/2662)) - Remove deprecated loggers ([#2685](https://github.com/getsentry/sentry-dart/pull/2685)) - Remove user segment ([#2687](https://github.com/getsentry/sentry-dart/pull/2687)) +- Remove `enableTracing` ([#2695](https://github.com/getsentry/sentry-dart/pull/2695)) - Remove `options.autoAppStart` and `setAppStartEnd` ([#2680](https://github.com/getsentry/sentry-dart/pull/2680)) - Add hint for transactions ([#2675](https://github.com/getsentry/sentry-dart/pull/2675)) - `BeforeSendTransactionCallback` now has a `Hint` parameter diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index e4e7b3fe1d..5af65fe6be 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -441,13 +441,6 @@ class SentryOptions { _stackTraceExtractorsByType[extractor.exceptionType] = extractor; } - /// Enables generation of transactions and propagation of trace data. If set - /// to null, tracing might be enabled if [tracesSampleRate] or [tracesSampler] - /// are set. - @Deprecated( - 'Use either tracesSampleRate or tracesSampler instead. This will be removed in v9') - bool? enableTracing; - /// Only for internal use. Changed SDK behaviour when set to true: /// - Rethrow exceptions that occur in user provided closures @internal @@ -557,11 +550,6 @@ class SentryOptions { /// Returns if tracing should be enabled. If tracing is disabled, starting transactions returns /// [NoOpSentrySpan]. bool isTracingEnabled() { - // ignore: deprecated_member_use_from_same_package - final enable = enableTracing; - if (enable != null) { - return enable; - } return tracesSampleRate != null || tracesSampler != null; } diff --git a/dart/lib/src/sentry_traces_sampler.dart b/dart/lib/src/sentry_traces_sampler.dart index f668ad460f..1b4634aee5 100644 --- a/dart/lib/src/sentry_traces_sampler.dart +++ b/dart/lib/src/sentry_traces_sampler.dart @@ -6,8 +6,6 @@ import '../sentry.dart'; @internal class SentryTracesSampler { - static const _defaultSampleRate = 1.0; - final SentryOptions _options; final Random _random; @@ -55,13 +53,8 @@ class SentryTracesSampler { } double? optionsRate = _options.tracesSampleRate; - double? defaultRate = - // ignore: deprecated_member_use_from_same_package - _options.enableTracing == true ? _defaultSampleRate : null; - double? optionsOrDefaultRate = optionsRate ?? defaultRate; - - if (optionsOrDefaultRate != null) { - return _makeSampleDecision(optionsOrDefaultRate); + if (optionsRate != null) { + return _makeSampleDecision(optionsRate); } return SentryTracesSamplingDecision(false); diff --git a/dart/test/http_client/tracing_client_test.dart b/dart/test/http_client/tracing_client_test.dart index 4e052dc518..7c34281dfc 100644 --- a/dart/test/http_client/tracing_client_test.dart +++ b/dart/test/http_client/tracing_client_test.dart @@ -177,8 +177,9 @@ void main() { test('set headers from propagationContext when tracing is disabled', () async { - // ignore: deprecated_member_use_from_same_package - fixture._options.enableTracing = false; + fixture._options.tracesSampler = null; + fixture._options.tracesSampleRate = null; + final sut = fixture.getSut( client: fixture.getClient(statusCode: 200, reason: 'OK'), ); diff --git a/dart/test/sentry_options_test.dart b/dart/test/sentry_options_test.dart index 0afb4ce071..9a8bfe5153 100644 --- a/dart/test/sentry_options_test.dart +++ b/dart/test/sentry_options_test.dart @@ -107,26 +107,6 @@ void main() { expect(options.idleTimeout?.inSeconds, Duration(seconds: 3).inSeconds); }); - test('when enableTracing is set to true tracing is considered enabled', () { - final options = SentryOptions.empty(); - // ignore: deprecated_member_use_from_same_package - options.enableTracing = true; - - expect(options.isTracingEnabled(), true); - }); - - test('when enableTracing is set to false tracing is considered disabled', () { - final options = SentryOptions.empty(); - // ignore: deprecated_member_use_from_same_package - options.enableTracing = false; - options.tracesSampleRate = 1.0; - options.tracesSampler = (_) { - return 1.0; - }; - - expect(options.isTracingEnabled(), false); - }); - test('Spotlight is disabled by default', () { final options = defaultTestOptions(); diff --git a/dart/test/sentry_traces_sampler_test.dart b/dart/test/sentry_traces_sampler_test.dart index 3fbcb85772..8d0ca97f02 100644 --- a/dart/test/sentry_traces_sampler_test.dart +++ b/dart/test/sentry_traces_sampler_test.dart @@ -80,6 +80,21 @@ void main() { expect(sut.sample(context).sampled, false); }); + test('does not sample if tracesSampleRate and tracesSampleRate are null', () { + final sut = fixture.getSut(tracesSampleRate: null, tracesSampler: null); + + final trContext = SentryTransactionContext( + 'name', + 'op', + ); + final context = SentrySamplingContext(trContext, {}); + final samplingDecision = sut.sample(context); + + expect(samplingDecision.sampleRate, isNull); + expect(samplingDecision.sampleRand, isNull); + expect(samplingDecision.sampled, false); + }); + test('tracesSampler exception is handled', () { fixture.options.automatedTestMode = false; final sut = fixture.getSut(debug: true); @@ -101,54 +116,6 @@ void main() { expect(fixture.loggedException, exception); expect(fixture.loggedLevel, SentryLevel.error); }); - - test('when no tracesSampleRate is set, do not sample with enableTracing null', - () { - final sampler = fixture.getSut(tracesSampleRate: null, enableTracing: null); - final trContext = SentryTransactionContext( - 'name', - 'op', - parentSamplingDecision: null, - ); - final context = SentrySamplingContext(trContext, {}); - final samplingDecision = sampler.sample(context); - - expect(samplingDecision.sampleRate, isNull); - expect(samplingDecision.sampled, false); - }); - - test( - 'when no tracesSampleRate is set, do not sample with enableTracing false', - () { - final sampler = - fixture.getSut(tracesSampleRate: null, enableTracing: false); - final trContext = SentryTransactionContext( - 'name', - 'op', - parentSamplingDecision: null, - ); - final context = SentrySamplingContext(trContext, {}); - final samplingDecision = sampler.sample(context); - - expect(samplingDecision.sampleRate, isNull); - expect(samplingDecision.sampled, false); - }); - - test( - 'when no tracesSampleRate is set, uses default rate with enableTracing true', - () { - final sampler = fixture.getSut(tracesSampleRate: null, enableTracing: true); - final trContext = SentryTransactionContext( - 'name', - 'op', - parentSamplingDecision: null, - ); - final context = SentrySamplingContext(trContext, {}); - final samplingDecision = sampler.sample(context); - - expect(samplingDecision.sampled, true); - expect(1.0, samplingDecision.sampleRate); - }); } class Fixture { @@ -161,14 +128,11 @@ class Fixture { double? tracesSampleRate = 1.0, TracesSamplerCallback? tracesSampler, bool debug = false, - bool? enableTracing, }) { options.tracesSampleRate = tracesSampleRate; options.tracesSampler = tracesSampler; options.debug = debug; options.logger = mockLogger; - // ignore: deprecated_member_use_from_same_package - options.enableTracing = enableTracing; return SentryTracesSampler(options); } diff --git a/dio/test/tracing_client_adapter_test.dart b/dio/test/tracing_client_adapter_test.dart index 680825b34f..d4f6299366 100644 --- a/dio/test/tracing_client_adapter_test.dart +++ b/dio/test/tracing_client_adapter_test.dart @@ -137,7 +137,9 @@ void main() { test('set headers from propagationContext when tracing is disabled', () async { - fixture._options.enableTracing = false; + fixture._options.tracesSampleRate = null; + fixture._options.tracesSampler = null; + final sut = fixture.getSut( client: fixture.getClient(statusCode: 200, reason: 'OK'), );