Skip to content

Commit 891efac

Browse files
authored
chore: log warning if both tracesSampleRate and tracesSampler are set (#1701)
* Log warning if both tracesSampleRate and tracesSampler are set * Update CHANGELOG * Update log * Update CHANGELOG
1 parent ed2ae08 commit 891efac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Enhancements
6+
7+
- Log warning if both tracesSampleRate and tracesSampler are set ([#1701](https://github.com/getsentry/sentry-dart/pull/1701))
8+
59
### Features
610

711
- Initial (alpha) support for profiling on iOS and macOS ([#1611](https://github.com/getsentry/sentry-dart/pull/1611))

dart/lib/src/sentry_traces_sampler.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ class SentryTracesSampler {
1414
SentryTracesSampler(
1515
this._options, {
1616
Random? random,
17-
}) : _random = random ?? Random();
17+
}) : _random = random ?? Random() {
18+
if (_options.tracesSampler != null && _options.tracesSampleRate != null) {
19+
_options.logger(SentryLevel.warning,
20+
'Both tracesSampler and traceSampleRate are set. tracesSampler will take precedence and fallback to traceSampleRate if it returns null.');
21+
}
22+
}
1823

1924
SentryTracesSamplingDecision sample(SentrySamplingContext samplingContext) {
2025
final samplingDecision =

0 commit comments

Comments
 (0)