@@ -65,6 +65,9 @@ public function testHandleKernelRequestEvent(Options $options, Request $request,
65
65
$ this ->hub ->expects ($ this ->once ())
66
66
->method ('startTransaction ' )
67
67
->with ($ this ->callback (function (TransactionContext $ context ) use ($ expectedTransactionContext ): bool {
68
+ // This value is random when the metadata is constructed, thus we set it to a fixed expected value since we don't care for the value here
69
+ $ context ->getMetadata ()->setSampleRand (0.1337 );
70
+
68
71
$ this ->assertEquals ($ expectedTransactionContext , $ context );
69
72
70
73
return true ;
@@ -108,6 +111,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
108
111
'net.host.name ' => 'www.example.com ' ,
109
112
]);
110
113
$ transactionContext ->getMetadata ()->setDynamicSamplingContext ($ samplingContext );
114
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
111
115
112
116
yield 'request.headers.sentry-trace EXISTS ' => [
113
117
new Options (),
@@ -146,6 +150,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
146
150
'net.host.name ' => 'www.example.com ' ,
147
151
]);
148
152
$ transactionContext ->getMetadata ()->setDynamicSamplingContext ($ samplingContext );
153
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
149
154
150
155
yield 'request.headers.traceparent EXISTS ' => [
151
156
new Options (),
@@ -184,6 +189,8 @@ public function handleKernelRequestEventDataProvider(): \Generator
184
189
'net.host.name ' => 'www.example.com ' ,
185
190
]);
186
191
$ transactionContext ->getMetadata ()->setDynamicSamplingContext ($ samplingContext );
192
+ $ transactionContext ->getMetadata ()->setParentSamplingRate (1.0 );
193
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
187
194
188
195
yield 'request.headers.sentry-trace and headers.baggage EXISTS ' => [
189
196
new Options (),
@@ -216,6 +223,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
216
223
'route ' => '<unknown> ' ,
217
224
'net.host.name ' => 'www.example.com ' ,
218
225
]);
226
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
219
227
220
228
$ request = Request::create ('http://www.example.com ' );
221
229
$ request ->server ->remove ('REQUEST_TIME_FLOAT ' );
@@ -240,6 +248,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
240
248
'route ' => '<unknown> ' ,
241
249
'net.host.ip ' => '127.0.0.1 ' ,
242
250
]);
251
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
243
252
244
253
yield 'request.server.HOST IS IPV4 ' => [
245
254
new Options (),
@@ -272,6 +281,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
272
281
'route ' => 'app_homepage ' ,
273
282
'net.host.name ' => 'www.example.com ' ,
274
283
]);
284
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
275
285
276
286
yield 'request.attributes.route IS STRING ' => [
277
287
new Options (),
@@ -297,6 +307,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
297
307
'route ' => '/path ' ,
298
308
'net.host.name ' => 'www.example.com ' ,
299
309
]);
310
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
300
311
301
312
yield 'request.attributes.route IS INSTANCEOF Symfony\Component\Routing\Route ' => [
302
313
new Options (),
@@ -322,6 +333,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
322
333
'route ' => 'App \\Controller::indexAction ' ,
323
334
'net.host.name ' => 'www.example.com ' ,
324
335
]);
336
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
325
337
326
338
yield 'request.attributes._controller IS STRING ' => [
327
339
new Options (),
@@ -347,6 +359,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
347
359
'route ' => 'App \\Controller::indexAction ' ,
348
360
'net.host.name ' => 'www.example.com ' ,
349
361
]);
362
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
350
363
351
364
yield 'request.attributes._controller IS CALLABLE (1) ' => [
352
365
new Options (),
@@ -372,6 +385,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
372
385
'route ' => 'class@anonymous::indexAction ' ,
373
386
'net.host.name ' => 'www.example.com ' ,
374
387
]);
388
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
375
389
376
390
yield 'request.attributes._controller IS CALLABLE (2) ' => [
377
391
new Options (),
@@ -397,6 +411,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
397
411
'route ' => '<unknown> ' ,
398
412
'net.host.name ' => 'www.example.com ' ,
399
413
]);
414
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
400
415
401
416
yield 'request.attributes._controller IS ARRAY and NOT VALID CALLABLE ' => [
402
417
new Options (),
@@ -423,6 +438,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
423
438
'net.host.name ' => 'www.example.com ' ,
424
439
'net.peer.ip ' => '127.0.0.1 ' ,
425
440
]);
441
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
426
442
427
443
yield 'request.server.REMOTE_ADDR EXISTS and client.options.send_default_pii = TRUE ' => [
428
444
new Options (['send_default_pii ' => true ]),
@@ -446,6 +462,7 @@ public function handleKernelRequestEventDataProvider(): \Generator
446
462
'route ' => '<unknown> ' ,
447
463
'net.host.name ' => '' ,
448
464
]);
465
+ $ transactionContext ->getMetadata ()->setSampleRand (0.1337 );
449
466
450
467
yield 'request.server.SERVER_PROTOCOL NOT EXISTS ' => [
451
468
new Options (),
0 commit comments