From 99356e2abbe4eeb908de1ea463005078f35ae8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Fri, 24 Nov 2023 05:51:59 +0100 Subject: [PATCH 1/2] Test with php 8.3 (#138) * Add testing on PHP 8.3 * Move all tests to php 8.3 and remove testing for PHP 7.4 as it is EOL. --- .github/workflows/blackbox.yml | 2 +- .github/workflows/checks.yml | 4 ++-- .github/workflows/tests.yml | 2 +- php-fpm/Dockerfile | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/blackbox.yml b/.github/workflows/blackbox.yml index 2944b233..024edd07 100644 --- a/.github/workflows/blackbox.yml +++ b/.github/workflows/blackbox.yml @@ -22,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - name: Install dependencies diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4bd07bf4..a9564c3d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,7 +20,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none - name: Install dependencies @@ -34,10 +34,10 @@ jobs: fail-fast: false matrix: php: - - "7.4" - "8.0" - "8.1" - "8.2" + - "8.3" name: PHPStan on PHP ${{ matrix.php }} steps: - name: Checkout code diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index baafb6ad..8e33fae5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [ 7.4, 8.0, 8.1, 8.2 ] + php: [ 8.0, 8.1, 8.2, 8.3 ] dependency-version: [ prefer-lowest, prefer-stable ] redis-version: [ 5, 6, 7 ] diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index f0d50190..5cc69b6a 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm +FROM php:8.2-fpm RUN pecl install redis && docker-php-ext-enable redis RUN pecl install apcu && docker-php-ext-enable apcu From 7e70cebf9538d3994da0fdce2d42c6356c2f4ecf Mon Sep 17 00:00:00 2001 From: vlahanas Date: Fri, 24 Nov 2023 07:11:56 +0200 Subject: [PATCH 2/2] Include metric name in exception message (#131) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add metric name in the runtime exception message which is thrown when escapeAllLabels fails to combine labels. Signed-off-by: vlahanas Co-authored-by: Lukas Kämmerling --- src/Prometheus/RenderTextFormat.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Prometheus/RenderTextFormat.php b/src/Prometheus/RenderTextFormat.php index 98ee73ea..b160865c 100644 --- a/src/Prometheus/RenderTextFormat.php +++ b/src/Prometheus/RenderTextFormat.php @@ -40,7 +40,7 @@ private function renderSample(MetricFamilySamples $metric, Sample $sample): stri { $labelNames = $metric->getLabelNames(); if ($metric->hasLabelNames() || $sample->hasLabelNames()) { - $escapedLabels = $this->escapeAllLabels($labelNames, $sample); + $escapedLabels = $this->escapeAllLabels($metric, $labelNames, $sample); return $sample->getName() . '{' . implode(',', $escapedLabels) . '} ' . $sample->getValue(); } return $sample->getName() . ' ' . $sample->getValue(); @@ -56,19 +56,20 @@ private function escapeLabelValue(string $v): string } /** + * @param MetricFamilySamples $metric * @param string[] $labelNames * @param Sample $sample * * @return string[] */ - private function escapeAllLabels(array $labelNames, Sample $sample): array + private function escapeAllLabels(MetricFamilySamples $metric, array $labelNames, Sample $sample): array { $escapedLabels = []; $labels = array_combine(array_merge($labelNames, $sample->getLabelNames()), $sample->getLabelValues()); if ($labels === false) { - throw new RuntimeException('Unable to combine labels.'); + throw new RuntimeException('Unable to combine labels for metric named ' . $metric->getName()); } foreach ($labels as $labelName => $labelValue) {