in agent/php/ElasticApm/Impl/InferredSpansManager.php [155:219]
private function onNewCurrentTransactionHasBegun(Transaction $transaction): void
{
($loggerProxy = $this->logger->ifTraceLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('Entered', ['transaction' => $transaction]);
if ($this->isShutdown()) {
return;
}
if ($this->currentTransaction !== null) {
($loggerProxy = $this->logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log(
'Unexpected: New transaction has begun'
. ' while there is already a transaction in progress'
. ' - shutting down...',
['old transaction' => $this->currentTransaction, 'new transaction' => $transaction]
);
$this->shutdown();
return;
}
if ($transaction !== $this->tracer->getCurrentTransaction()) {
($loggerProxy = $this->logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log(
"Unexpected: New transaction has begun but it's not the current transaction"
. ' - shutting down...',
['new transaction' => $transaction, 'current transaction' => $this->tracer->getCurrentTransaction()]
);
$this->shutdown();
return;
}
($assertProxy = Assert::ifEnabled())
&& $assertProxy->that($this->state === self::STATE_WAITING_FOR_NEW_TRANSACTION)
&& $assertProxy->withContext('$this->state === self::STATE_WAITING_FOR_NEW_TRANSACTION', ['this' => $this]);
($assertProxy = Assert::ifEnabled())
&& $assertProxy->that($this->currentTransaction === null)
&& $assertProxy->withContext('$this->currentTransaction === null', ['this' => $this]);
$this->currentTransaction = $transaction;
($assertProxy = Assert::ifEnabled())
&& $assertProxy->that($this->onCurrentTransactionAboutToEndCallback === null)
&& $assertProxy->withContext('$this->onTransactionAboutToEndCallback === null', ['this' => $this]);
$this->currentTransaction->onAboutToEnd->add(
$this->onCurrentTransactionAboutToEndCallback = function (Transaction $transaction): void {
$this->onCurrentTransactionAboutToEnd($transaction);
}
);
($assertProxy = Assert::ifEnabled())
&& $assertProxy->that($this->onCurrentSpanChangedCallback === null)
&& $assertProxy->withContext('$this->onCurrentSpanChangedCallback === null', ['this' => $this]);
if ($this->currentTransaction !== null) {
$this->currentTransaction->onCurrentSpanChanged->add(
$this->onCurrentSpanChangedCallback = function (?Span $span): void {
$this->onCurrentSpanChanged($span);
}
);
}
$this->builder = new InferredSpansBuilder($this->tracer);
$this->state = self::STATE_RUNNING;
}