Skip to content

Commit 405ac6b

Browse files
authored
Merge pull request #4 from ensi-platform/apcu_support
convert all label values to string if apcu adapted is used.
2 parents 69f14a4 + c00f477 commit 405ac6b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/MetricsBag.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,27 @@ private function isPrometheusEnabled(): bool
102102
return config('prometheus.enabled');
103103
}
104104

105+
private function apcuNgAdapterIsUsed(): bool
106+
{
107+
return isset($this->config['apcu-ng']);
108+
}
109+
105110
public function update(string $name, $value, array $labelValues = []): void
106111
{
107112
if (!$this->isPrometheusEnabled()) {
108113
return;
109114
}
110115

116+
if ($this->apcuNgAdapterIsUsed()) {
117+
$labelValues = array_map(function ($labelValue) {
118+
if (!is_string($labelValue)) {
119+
$labelValue = json_encode($labelValue);
120+
}
121+
122+
return $labelValue;
123+
}, $labelValues);
124+
}
125+
111126
$metric = $this->metrics[$name] ?? null;
112127
$metric?->update($value, $labelValues);
113128
}

0 commit comments

Comments
 (0)