in agent/php/ElasticApm/Impl/AutoInstrument/PDOAutoInstrumentation.php [270:326]
private function interceptPDOStatementExecute(RegistrationContextInterface $ctx): void
{
$className = self::PDO_STATEMENT_CLASS_NAME;
$methodName = 'execute';
$ctx->interceptCallsToInternalMethod(
$className,
$methodName,
/**
* @param ?object $interceptedCallThis
* @param mixed[] $interceptedCallArgs
*
* @return callable
*
*/
function (
?object $interceptedCallThis,
/** @noinspection PhpUnusedParameterInspection */ array $interceptedCallArgs
) use (
$className,
$methodName
): ?callable {
if (!$this->util->verifyInstanceOf(PDOStatement::class, $interceptedCallThis)) {
return null;
}
/** @var PDOStatement $interceptedCallThis */
$statement = (
isset($interceptedCallThis->queryString)
&& $this->util->verifyIsString($interceptedCallThis->queryString)
)
? $interceptedCallThis->queryString
: null;
/** @var string $dbType */
$dbType = $this->mapPerObject->getOr(
$interceptedCallThis,
DbAutoInstrumentationUtil::PER_OBJECT_KEY_DB_TYPE,
Constants::SPAN_SUBTYPE_UNKNOWN /* <- defaultValue */
);
/** @var ?string $dbName */
$dbName = $this->mapPerObject->getOr(
$interceptedCallThis,
DbAutoInstrumentationUtil::PER_OBJECT_KEY_DB_NAME,
null /* <- defaultValue */
);
return AutoInstrumentationUtil::createInternalFuncPostHookFromEndSpan(
DbAutoInstrumentationUtil::beginDbSpan(
$className,
$methodName,
$dbType,
$dbName,
$statement
)
);
}
);
}