Skip to content

Commit

Permalink
Fix tracing sampling considering sample_rate rather than the traces_s…
Browse files Browse the repository at this point in the history
…ample_rate option (#1106)
  • Loading branch information
stayallive committed Oct 2, 2020
1 parent b392480 commit 001f2e2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fix: Use the traces sample rate for traces instead of the event sample rate (#1106)

## 3.0.1 (2020-10-01)

- fix: Use Span on Scope instead of Transaction for GuzzleMiddleware (#1099)
Expand Down
2 changes: 1 addition & 1 deletion src/State/Hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function startTransaction(TransactionContext $context): Transaction
$tracesSampler = $options->getTracesSampler();
$sampleRate = null !== $tracesSampler
? $tracesSampler($samplingContext)
: $this->getSampleRate($samplingContext->getParentSampled(), $options->getSampleRate());
: $this->getSampleRate($samplingContext->getParentSampled(), $options->getTracesSampleRate());

if (!$this->isValidSampleRate($sampleRate)) {
$transaction->setSampled(false);
Expand Down
18 changes: 18 additions & 0 deletions tests/State/HubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,24 @@ public function startTransactionDataProvider(): iterable
false,
];

yield [
new Options([
'sample_rate' => 1.0,
'traces_sample_rate' => 0.0,
]),
new TransactionContext(),
false,
];

yield [
new Options([
'sample_rate' => 0.0,
'traces_sample_rate' => 1.0,
]),
new TransactionContext(),
true,
];

yield [
new Options([
'traces_sample_rate' => 0.5,
Expand Down

0 comments on commit 001f2e2

Please sign in to comment.