Skip to content

Commit

Permalink
Merge branch 'main' into feature/verbose_exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
LKaemmerling authored Nov 24, 2023
2 parents bed61be + 7e70ceb commit 522016d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/blackbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]

Expand Down
2 changes: 1 addition & 1 deletion php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Prometheus/RenderTextFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down

0 comments on commit 522016d

Please sign in to comment.