private function discoverHttpName()

in agent/php/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php [521:560]


    private function discoverHttpName(): string
    {
        if ($this->urlParts === null || $this->urlParts->path === null) {
            ($loggerProxy = $this->logger->ifErrorLevelEnabled(__LINE__, __FUNCTION__))
            && $loggerProxy->log(
                'Failed to  discover path part of URL to derive transaction name - using default transaction name',
                ['DEFAULT_NAME' => self::DEFAULT_NAME]
            );
            return self::DEFAULT_NAME;
        }

        $urlGroupsMatcher = $this->tracer->getConfig()->urlGroups();
        $urlPath = $this->urlParts->path;

        $urlPathGroup = WildcardListMatcher::matchNullable($urlGroupsMatcher, $urlPath);
        if ($urlPathGroup !== null) {
            ($loggerProxy = $this->logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
            && $loggerProxy->log(
                'For transaction name URL path is mapped to matched URL group',
                [
                    'urlPath'                                  => $urlPath,
                    'matched URL group'                        => $urlPathGroup,
                    OptionNames::URL_GROUPS . ' configuration' => $urlGroupsMatcher,
                ]
            );
        }

        if ($urlPathGroup === null) {
            $urlPathGroup = $urlPath;
        }

        $name = ($this->httpMethod === null)
            ? $urlPathGroup
            : ($this->httpMethod . ' ' . $urlPathGroup);

        ($loggerProxy = $this->logger->ifDebugLevelEnabled(__LINE__, __FUNCTION__))
        && $loggerProxy->log('Successfully discovered HTTP data to derive transaction name', ['name' => $name]);

        return $name;
    }