Skip to content

Commit

Permalink
Add the sampling decision to the trace envelope header (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric authored Jul 10, 2023
1 parent b985656 commit 4bab1dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Tracing/DynamicSamplingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ public static function fromTransaction(Transaction $transaction, HubInterface $h
}
});

if (null !== $transaction->getSampled()) {
$samplingContext->set('sampled', $transaction->getSampled() ? 'true' : 'false');
}

$samplingContext->freeze();

return $samplingContext;
Expand Down
2 changes: 1 addition & 1 deletion tests/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public function testBaggageWithTracingEnabled(): void

$baggage = getBaggage();

$this->assertSame('sentry-trace_id=566e3688a61d4bc888951642d6f14a19,sentry-sample_rate=1,sentry-transaction=Test,sentry-release=1.0.0,sentry-environment=development', $baggage);
$this->assertSame('sentry-trace_id=566e3688a61d4bc888951642d6f14a19,sentry-sample_rate=1,sentry-transaction=Test,sentry-release=1.0.0,sentry-environment=development,sentry-sampled=true', $baggage);
}

public function testContinueTrace(): void
Expand Down

0 comments on commit 4bab1dc

Please sign in to comment.