11
11
use Sentry \SentryBundle \Tracing \HttpClient \AbstractTraceableResponse ;
12
12
use Sentry \SentryBundle \Tracing \HttpClient \TraceableHttpClient ;
13
13
use Sentry \State \HubInterface ;
14
+ use Sentry \Tracing \DynamicSamplingContext ;
14
15
use Sentry \Tracing \Transaction ;
15
16
use Sentry \Tracing \TransactionContext ;
16
17
use Symfony \Component \HttpClient \MockHttpClient ;
@@ -51,7 +52,12 @@ protected function setUp(): void
51
52
52
53
public function testRequest (): void
53
54
{
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 );
55
61
$ transaction ->initSpanRecorder ();
56
62
57
63
$ this ->hub ->expects ($ this ->once ())
@@ -68,6 +74,7 @@ public function testRequest(): void
68
74
$ this ->assertSame ('GET ' , $ response ->getInfo ('http_method ' ));
69
75
$ this ->assertSame ('https://www.example.com/test-page ' , $ response ->getInfo ('url ' ));
70
76
$ this ->assertSame (['sentry-trace: ' . $ transaction ->toTraceparent ()], $ mockResponse ->getRequestOptions ()['normalized_headers ' ]['sentry-trace ' ]);
77
+ $ this ->assertSame (['baggage: ' . $ transaction ->toBaggage ()], $ mockResponse ->getRequestOptions ()['normalized_headers ' ]['baggage ' ]);
71
78
$ this ->assertNotNull ($ transaction ->getSpanRecorder ());
72
79
73
80
$ spans = $ transaction ->getSpanRecorder ()->getSpans ();
0 commit comments