@@ -269,6 +269,7 @@ public function startTransaction(TransactionContext $context, array $customSampl
269269 $ samplingContext ->setAdditionalContext ($ customSamplingContext );
270270
271271 $ sampleSource = 'context ' ;
272+ $ sampleRand = $ context ->getMetadata ()->getSampleRand ();
272273
273274 if ($ transaction ->getSampled () === null ) {
274275 $ tracesSampler = $ options ->getTracesSampler ();
@@ -278,12 +279,17 @@ public function startTransaction(TransactionContext $context, array $customSampl
278279
279280 $ sampleSource = 'config:traces_sampler ' ;
280281 } else {
281- $ sampleRate = $ this ->getSampleRate (
282- $ samplingContext ->getParentSampled (),
283- $ options ->getTracesSampleRate () ?? 0
284- );
285-
286- $ sampleSource = $ samplingContext ->getParentSampled () ? 'parent ' : 'config:traces_sample_rate ' ;
282+ $ parentSampleRate = (float ) $ context ->getMetadata ()->getDynamicSamplingContext ()->get ('sample_rate ' );
283+ if ($ parentSampleRate !== null ) {
284+ $ sampleRate = $ parentSampleRate ;
285+ $ sampleSource = 'parent ' ;
286+ } else {
287+ $ sampleRate = $ this ->getSampleRate (
288+ $ samplingContext ->getParentSampled (),
289+ $ options ->getTracesSampleRate () ?? 0
290+ );
291+ $ sampleSource = $ samplingContext ->getParentSampled () ? 'parent ' : 'config:traces_sample_rate ' ;
292+ }
287293 }
288294
289295 if (!$ this ->isValidSampleRate ($ sampleRate )) {
@@ -294,6 +300,7 @@ public function startTransaction(TransactionContext $context, array $customSampl
294300 return $ transaction ;
295301 }
296302
303+ // TODO Why are we doing this?
297304 $ transaction ->getMetadata ()->setSamplingRate ($ sampleRate );
298305
299306 if ($ sampleRate === 0.0 ) {
0 commit comments