Skip to content

Commit 2fa029a

Browse files
committed
Extend TraceableHttpClientTest
1 parent ad36a73 commit 2fa029a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/Tracing/HttpClient/TraceableHttpClientTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Sentry\SentryBundle\Tracing\HttpClient\AbstractTraceableResponse;
1212
use Sentry\SentryBundle\Tracing\HttpClient\TraceableHttpClient;
1313
use Sentry\State\HubInterface;
14+
use Sentry\Tracing\DynamicSamplingContext;
1415
use Sentry\Tracing\Transaction;
1516
use Sentry\Tracing\TransactionContext;
1617
use Symfony\Component\HttpClient\MockHttpClient;
@@ -51,7 +52,12 @@ protected function setUp(): void
5152

5253
public function testRequest(): void
5354
{
54-
$transaction = new Transaction(new TransactionContext());
55+
$samplingContext = DynamicSamplingContext::fromHeader('sentry-trace_id=566e3688a61d4bc888951642d6f14a19,sentry-public_key=public,sentry-sample_rate=1');
56+
57+
$transactionContext = new TransactionContext();
58+
$transactionContext->getMetadata()->setDynamicSamplingContext($samplingContext);
59+
60+
$transaction = new Transaction($transactionContext);
5561
$transaction->initSpanRecorder();
5662

5763
$this->hub->expects($this->once())
@@ -68,6 +74,7 @@ public function testRequest(): void
6874
$this->assertSame('GET', $response->getInfo('http_method'));
6975
$this->assertSame('https://www.example.com/test-page', $response->getInfo('url'));
7076
$this->assertSame(['sentry-trace: ' . $transaction->toTraceparent()], $mockResponse->getRequestOptions()['normalized_headers']['sentry-trace']);
77+
$this->assertSame(['baggage: ' . $transaction->toBaggage()], $mockResponse->getRequestOptions()['normalized_headers']['baggage']);
7178
$this->assertNotNull($transaction->getSpanRecorder());
7279

7380
$spans = $transaction->getSpanRecorder()->getSpans();

0 commit comments

Comments
 (0)