From 2e4c849b2f93ba21a18394400b2cfeb0e52aa661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erdem=20K=C3=B6se?= Date: Wed, 18 May 2022 04:10:08 +0200 Subject: [PATCH] Allow custom counters implementing CounterInterface to be exported (#676) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erdem Köse --- src/Contrib/Prometheus/PrometheusExporter.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Contrib/Prometheus/PrometheusExporter.php b/src/Contrib/Prometheus/PrometheusExporter.php index 7c30912cb..89c4a3f78 100644 --- a/src/Contrib/Prometheus/PrometheusExporter.php +++ b/src/Contrib/Prometheus/PrometheusExporter.php @@ -5,7 +5,6 @@ namespace OpenTelemetry\Contrib\Prometheus; use OpenTelemetry\API\Metrics as API; -use OpenTelemetry\SDK\Metrics\Counter; use OpenTelemetry\SDK\Metrics\Exceptions\CantBeExported; use OpenTelemetry\SDK\Metrics\Exporters\AbstractExporter; use Prometheus\CollectorRegistry; @@ -28,8 +27,8 @@ public function __construct(CollectorRegistry $registry, string $namespace = '') protected function doExport(iterable $metrics): void { foreach ($metrics as $metric) { - switch (get_class($metric)) { - case Counter::class: + switch (true) { + case $metric instanceof API\CounterInterface: $this->exportCounter($metric); break;