diff --git a/CHANGELOG.md b/CHANGELOG.md index d47fa4801c..9a0e8ec9fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,14 @@ SentryFlutter.init((options) => options..prependExceptionTypeIdentifier(MyCustomExceptionIdentifier())); ``` +### Deprecated + +- Deprecate `enableTracing` ([#2199](https://github.com/getsentry/sentry-dart/pull/2199)) + - The `enableTracing` option has been deprecated and will be removed in the next major version. We recommend removing it + in favor of the `tracesSampleRate` and `tracesSampler` options. If you want to enable performance monitoring, please set + the `tracesSampleRate` to a sample rate of your choice, or provide a sampling function as `tracesSampler` option + instead. If you want to disable performance monitoring, remove the `tracesSampler` and `tracesSampleRate` options. + ### Dependencies - Bump Android SDK from v7.12.0 to v7.12.1 ([#2198](https://github.com/getsentry/sentry-dart/pull/2198)) diff --git a/dart/lib/src/sentry_options.dart b/dart/lib/src/sentry_options.dart index 5aef9de542..636534fb5d 100644 --- a/dart/lib/src/sentry_options.dart +++ b/dart/lib/src/sentry_options.dart @@ -398,6 +398,8 @@ class SentryOptions { /// 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; /// Enables sending developer metrics to Sentry. @@ -537,6 +539,7 @@ 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; diff --git a/dart/lib/src/sentry_traces_sampler.dart b/dart/lib/src/sentry_traces_sampler.dart index b1668084c9..b842514481 100644 --- a/dart/lib/src/sentry_traces_sampler.dart +++ b/dart/lib/src/sentry_traces_sampler.dart @@ -59,6 +59,7 @@ class SentryTracesSampler { double? optionsRate = _options.tracesSampleRate; double? defaultRate = + // ignore: deprecated_member_use_from_same_package _options.enableTracing == true ? _defaultSampleRate : null; double? optionsOrDefaultRate = optionsRate ?? defaultRate; diff --git a/dart/test/http_client/tracing_client_test.dart b/dart/test/http_client/tracing_client_test.dart index cc48d5cb37..6cefe626b3 100644 --- a/dart/test/http_client/tracing_client_test.dart +++ b/dart/test/http_client/tracing_client_test.dart @@ -177,6 +177,7 @@ void main() { test('set headers from propagationContext when tracing is disabled', () async { + // ignore: deprecated_member_use_from_same_package fixture._options.enableTracing = false; 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 3097597a92..ccd06d5bf0 100644 --- a/dart/test/sentry_options_test.dart +++ b/dart/test/sentry_options_test.dart @@ -112,6 +112,7 @@ void main() { 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); @@ -119,6 +120,7 @@ void main() { 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 = (_) { diff --git a/dart/test/sentry_traces_sampler_test.dart b/dart/test/sentry_traces_sampler_test.dart index d4938e1b28..276897e651 100644 --- a/dart/test/sentry_traces_sampler_test.dart +++ b/dart/test/sentry_traces_sampler_test.dart @@ -166,6 +166,7 @@ class Fixture { options.tracesSampler = tracesSampler; options.debug = debug; options.logger = mockLogger; + // ignore: deprecated_member_use_from_same_package options.enableTracing = enableTracing; return SentryTracesSampler(options); }