From 0c5426c21c3ebdfb57637fe92ff5d6b7c4499987 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 18 Nov 2024 18:07:41 +0100 Subject: [PATCH] feat: add metric name to MetricsRegistrationException Signed-off-by: Simon Podlipsky --- src/Prometheus/CollectorRegistry.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Prometheus/CollectorRegistry.php b/src/Prometheus/CollectorRegistry.php index 1a0be516..91d6ad2c 100644 --- a/src/Prometheus/CollectorRegistry.php +++ b/src/Prometheus/CollectorRegistry.php @@ -99,7 +99,7 @@ public function registerGauge(string $namespace, string $name, string $help, arr { $metricIdentifier = self::metricIdentifier($namespace, $name); if (isset($this->gauges[$metricIdentifier])) { - throw new MetricsRegistrationException("Metric already registered"); + throw new MetricsRegistrationException("Metric ` . $metricIdentifier . ` already registered"); } $this->gauges[$metricIdentifier] = new Gauge( $this->storageAdapter, @@ -159,7 +159,7 @@ public function registerCounter(string $namespace, string $name, string $help, a { $metricIdentifier = self::metricIdentifier($namespace, $name); if (isset($this->counters[$metricIdentifier])) { - throw new MetricsRegistrationException("Metric already registered"); + throw new MetricsRegistrationException("Metric ` . $metricIdentifier . ` already registered"); } $this->counters[$metricIdentifier] = new Counter( $this->storageAdapter, @@ -225,7 +225,7 @@ public function registerHistogram( ): Histogram { $metricIdentifier = self::metricIdentifier($namespace, $name); if (isset($this->histograms[$metricIdentifier])) { - throw new MetricsRegistrationException("Metric already registered"); + throw new MetricsRegistrationException("Metric ` . $metricIdentifier . ` already registered"); } $this->histograms[$metricIdentifier] = new Histogram( $this->storageAdapter, @@ -301,7 +301,7 @@ public function registerSummary( ): Summary { $metricIdentifier = self::metricIdentifier($namespace, $name); if (isset($this->summaries[$metricIdentifier])) { - throw new MetricsRegistrationException("Metric already registered"); + throw new MetricsRegistrationException("Metric ` . $metricIdentifier . ` already registered"); } $this->summaries[$metricIdentifier] = new Summary( $this->storageAdapter,