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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 2 additions & 9 deletions dart/lib/src/sentry_traces_sampler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import '../sentry.dart';

@internal
class SentryTracesSampler {
static const _defaultSampleRate = 1.0;

final SentryOptions _options;
final Random _random;

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions dart/test/http_client/tracing_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
Expand Down
20 changes: 0 additions & 20 deletions dart/test/sentry_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
66 changes: 15 additions & 51 deletions dart/test/sentry_traces_sampler_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand All @@ -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);
}

Expand Down
4 changes: 3 additions & 1 deletion dio/test/tracing_client_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
);
Expand Down
Loading