in agent/php/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php [166:233]
private function discoverHttpRequestData(): bool
{
/** @phpstan-ignore-next-line */
if (!self::isGlobalServerVarSet()) {
($loggerProxy = $this->logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log('$_SERVER variable is not populated - forcing PHP engine to populate it...');
/** @phpstan-ignore-next-line */
if (!self::isGlobalServerVarSet()) {
($loggerProxy = $this->logger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log(
'$_SERVER variable is not populated even after forcing PHP engine to populate it'
. ' - agent will have to fallback on defaults'
);
return true;
}
}
/** @var ?string $urlPath */
$urlPath = null;
/** @var ?string $urlQuery */
$urlQuery = null;
$pathQuery = $this->getMandatoryServerVarStringElement('REQUEST_URI');
if (is_string($pathQuery)) {
UrlUtil::splitPathQuery($pathQuery, /* ref */ $urlPath, /* ref */ $urlQuery);
if ($urlPath === null) {
($loggerProxy = $this->logger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log(
'Failed to extract path part from $_SERVER["REQUEST_URI"]',
['$_SERVER["REQUEST_URI"]' => $pathQuery]
);
} else {
if ($this->shouldHttpTransactionBeIgnored($urlPath)) {
return false;
}
}
}
$this->httpMethod = $this->getMandatoryServerVarStringElement('REQUEST_METHOD');
$this->urlParts = new UrlParts();
$this->urlParts->path = $urlPath;
$this->urlParts->query = $urlQuery;
$serverHttps = self::getOptionalServerVarElement('HTTPS');
$this->urlParts->scheme = !empty($serverHttps) ? 'https' : 'http';
$hostPort = $this->getMandatoryServerVarStringElement('HTTP_HOST');
if ($hostPort !== null) {
UrlUtil::splitHostPort($hostPort, /* ref */ $this->urlParts->host, /* ref */ $this->urlParts->port);
if ($this->urlParts->host === null) {
($loggerProxy = $this->logger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
&& $loggerProxy->log(
'Failed to extract host part from $_SERVER["HTTP_HOST"]',
['$_SERVER["HTTP_HOST"]' => $hostPort]
);
}
}
$queryString = self::getOptionalServerVarElement('QUERY_STRING');
if (is_string($queryString)) {
$this->urlParts->query = $queryString;
}
$this->fullUrl = self::buildFullUrl($this->urlParts->scheme, $hostPort, $pathQuery);
return true;
}