<commit_before><?php


namespace Prometheus;


use GuzzleHttp\Client;

class PushGateway
{
    private $host;

    /**
     * PushGateway constructor.
     * @param $host string host name of the push gateway
     */
    public function __construct($host)
    {
        $this->host = $host;
    }

    /**
     * Pushes all metrics in a Collector, replacing all those with the same job.
     * @param CollectorRegistry $collectorRegistry
     * @param $job
     * @param $groupingKey
     */
    public function push(CollectorRegistry $collectorRegistry, $job, $groupingKey = null)
    {
        $url = "http://" . $this->host . "/metrics/job/" . $job;
        if (!empty($groupingKey)) {
            foreach ($groupingKey as $label => $value) {
                $url .= "/" . $label . "/" . $value;
            }
        }
        $renderer = new RenderTextFormat();
        $textData = $renderer->render($collectorRegistry->getMetricFamilySamples());
        $client = new Client();
        $response = $client->post($url, array(
            'headers' => array(
                'Content-Type' => RenderTextFormat::MIME_TYPE
            ),
            'body' => $textData,
            'connect_timeout' => 10,
            'timeout' => 20,
        ));
        $statusCode = $response->getStatusCode();
        if ($statusCode != 202) {
            $msg = "Unexpected status code " . $statusCode . " received from pushgateway " . $this->host . ": " . $response->getBody();
            throw new \RuntimeException($msg);
        }
    }
<commit_msg>Rename host to address<commit_after><?php


namespace Prometheus;


use GuzzleHttp\Client;

class PushGateway
{
    private $address;

    /**
     * PushGateway constructor.
     * @param $address string host:port of the push gateway
     */
    public function __construct($address)
    {
        $this->address = $address;
    }

    /**
     * Pushes all metrics in a Collector, replacing all those with the same job.
     * @param CollectorRegistry $collectorRegistry
     * @param $job
     * @param $groupingKey
     */
    public function push(CollectorRegistry $collectorRegistry, $job, $groupingKey = null)
    {
        $url = "http://" . $this->address . "/metrics/job/" . $job;
        if (!empty($groupingKey)) {
            foreach ($groupingKey as $label => $value) {
                $url .= "/" . $label . "/" . $value;
            }
        }
        $renderer = new RenderTextFormat();
        $textData = $renderer->render($collectorRegistry->getMetricFamilySamples());
        $client = new Client();
        $response = $client->post($url, array(
            'headers' => array(
                'Content-Type' => RenderTextFormat::MIME_TYPE
            ),
            'body' => $textData,
            'connect_timeout' => 10,
            'timeout' => 20,
        ));
        $statusCode = $response->getStatusCode();
        if ($statusCode != 202) {
            $msg = "Unexpected status code " . $statusCode . " received from pushgateway " . $this->address . ": " . $response->getBody();
            throw new \RuntimeException($msg);
        }
    }

{'fraction_non_alphanumeric': 0.14134615384615384, 'fraction_numerical': 0.004487179487179487, 'mean_word_length': 1.9980787704130643, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3078691', 'n_tokens_mistral': 902, 'n_tokens_neox': 881, 'n_words': 214}