From 7a0ad4ba332735ca8f6479cc44193618b53993c0 Mon Sep 17 00:00:00 2001 From: Marsel Markhabulin Date: Tue, 26 May 2020 12:13:04 +0300 Subject: [PATCH 1/4] Add typecasting for Redis connect function. Some libraries, frameworks of configs might provide a strings to port and timeout params. Redis extension on PHP 7.4 throw an TypeError on that situation. For preventing this add typecasting `(int)$this->options['port']` and `(float)$this->options['timeout']` to the `connect` and `pconnect` methods. --- src/Prometheus/Storage/Redis.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 5570685..c42e367 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -147,12 +147,12 @@ private function connectToServer(): bool if ($this->options['persistent_connections']) { return $this->redis->pconnect( $this->options['host'], - $this->options['port'], - $this->options['timeout'] + (int)$this->options['port'], + (float)$this->options['timeout'] ); } - return $this->redis->connect($this->options['host'], $this->options['port'], $this->options['timeout']); + return $this->redis->connect($this->options['host'], (int)$this->options['port'], (float)$this->options['timeout']); } catch (\RedisException $e) { return false; } From 600ad73d4ab134df5eb08c4e760a899f39afd2e4 Mon Sep 17 00:00:00 2001 From: Marsel Markhabulin Date: Tue, 29 Sep 2020 11:01:12 +0300 Subject: [PATCH 2/4] Upgrade guzzle version. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f2f8b90..5cb37b4 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "endclothing/prometheus_client_php", + "name": "satariall/prometheus_client_php", "description": "Prometheus instrumentation library for PHP applications.", "type": "library", "license": "Apache-2.0", @@ -15,7 +15,7 @@ "require": { "php": "^7.2", "ext-json": "*", - "guzzlehttp/guzzle": "^6.3", + "guzzlehttp/guzzle": "^7.0.1", "symfony/polyfill-apcu": "^1.6" }, "require-dev": { From f829f0154d323fb9fe639516ec1f563627f13c1c Mon Sep 17 00:00:00 2001 From: Marsel Markhabulin Date: Tue, 12 Jan 2021 12:07:49 +0300 Subject: [PATCH 3/4] Enable PHP 8 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5cb37b4..f13a353 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "jimdo/prometheus_client_php": "*" }, "require": { - "php": "^7.2", + "php": "^7.2||^8.0", "ext-json": "*", "guzzlehttp/guzzle": "^7.0.1", "symfony/polyfill-apcu": "^1.6" From 85a2128f6b8afe659415b7c98b2c96ba12b0c2be Mon Sep 17 00:00:00 2001 From: "prn.a_peskov" Date: Tue, 21 Nov 2023 11:58:47 +0300 Subject: [PATCH 4/4] fix(renderTextFormat): rendering histogram --- src/Prometheus/RenderTextFormat.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Prometheus/RenderTextFormat.php b/src/Prometheus/RenderTextFormat.php index a5b78dc..ede33ae 100644 --- a/src/Prometheus/RenderTextFormat.php +++ b/src/Prometheus/RenderTextFormat.php @@ -56,6 +56,7 @@ private function renderSample(MetricFamilySamples $metric, Sample $sample): stri */ private function escapeLabelValue($v): string { + $v = is_array($v) ? $v : (string) $v; $v = str_replace("\\", "\\\\", $v); $v = str_replace("\n", "\\n", $v); $v = str_replace("\"", "\\\"", $v);