diff --git a/src/Base/EApmEventBase.php b/src/Base/EApmEventBase.php index 2cc4538..b440cbf 100644 --- a/src/Base/EApmEventBase.php +++ b/src/Base/EApmEventBase.php @@ -135,6 +135,7 @@ class EApmEventBase * * EApmEventBase constructor. * @param EApmEventBase|null $parentEvent + * @throws \Exception */ public function __construct(?EApmEventBase $parentEvent = null) { diff --git a/src/EApmComposer.php b/src/EApmComposer.php index 0c4eca3..7595e2a 100644 --- a/src/EApmComposer.php +++ b/src/EApmComposer.php @@ -56,7 +56,7 @@ class EApmComposer * Agent version * @const */ - public const AGENT_VERSION = "1.1.1"; + public const AGENT_VERSION = "1.1.2"; /** * Agent name @@ -394,6 +394,7 @@ public function startNewTransaction(string $name, string $type) * @param EApmEventBase|null $parentEvent * * @return EApmTransaction + * @throws \Exception */ public function createNewTransaction(string $name, string $type, ?EApmEventBase $parentEvent = null) : EApmTransaction { @@ -404,9 +405,11 @@ public function createNewTransaction(string $name, string $type, ?EApmEventBase $transaction->setTraceId($this->getDistributeTrace()->getTraceId()); $transaction->setParentId($this->getDistributeTrace()->getParentSpanId()); } else { - $transaction->setTraceId( - EApmRandomIdUtil::RandomIdGenerate(EApmDistributeTrace::TRACEID_LENGTH / 2) - ); + if (is_null($transaction->getTraceId())) { + $transaction->setTraceId( + EApmRandomIdUtil::RandomIdGenerate(EApmDistributeTrace::TRACEID_LENGTH / 2) + ); + } } return $transaction; diff --git a/src/Events/EApmTransaction.php b/src/Events/EApmTransaction.php index 5dc902b..17b5f3b 100644 --- a/src/Events/EApmTransaction.php +++ b/src/Events/EApmTransaction.php @@ -85,9 +85,11 @@ public function __construct(string $name, string $type, ?EApmEventBase $parentEv $this->getComposer()->getDistributeTrace()->getParentSpanId() ); } else { - $this->setTraceId( - EApmRandomIdUtil::RandomIdGenerate(EApmDistributeTrace::TRACEID_LENGTH / 2) - ); + if (is_null($this->getTraceId())) { + $this->setTraceId( + EApmRandomIdUtil::RandomIdGenerate(EApmDistributeTrace::TRACEID_LENGTH / 2) + ); + } } } // prepare result