= 0 && $percentChance <= 100, '$percentChance', 'must be between 0 and 100 inclusive' ); $this->percentChance = $percentChance; } /** @inheritDoc */ public function shouldSample( ?SpanContext $parentSpanContext ): bool { if ( $parentSpanContext !== null ) { return $parentSpanContext->isSampled(); } return mt_rand( 1, 100 ) <= $this->percentChance; } }