From 633cd8c57d5ca97a8073efebff8d80621b7a1e99 Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Tue, 10 Oct 2023 22:57:58 +0400 Subject: [PATCH] Adds summary metric type (#11) --- src/Collector.php | 8 ++++++++ src/CollectorType.php | 1 + tests/Unit/CollectorTest.php | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/Collector.php b/src/Collector.php index 676bfd1..e99cfe5 100644 --- a/src/Collector.php +++ b/src/Collector.php @@ -107,4 +107,12 @@ public static function counter(): self { return new self(CollectorType::Counter); } + + /** + * New summary metric. + */ + public static function summary(): self + { + return new self(CollectorType::Summary); + } } diff --git a/src/CollectorType.php b/src/CollectorType.php index 21f5ba0..71de029 100644 --- a/src/CollectorType.php +++ b/src/CollectorType.php @@ -9,4 +9,5 @@ enum CollectorType: string case Histogram = 'histogram'; case Gauge = 'gauge'; case Counter = 'counter'; + case Summary = 'summary'; } diff --git a/tests/Unit/CollectorTest.php b/tests/Unit/CollectorTest.php index dfc4a58..3c6e0f0 100644 --- a/tests/Unit/CollectorTest.php +++ b/tests/Unit/CollectorTest.php @@ -74,6 +74,14 @@ public function testCounter(): void $this->assertSame([], $collector->toArray()['buckets']); } + public function testSummary(): void + { + $collector = Collector::summary(); + + $this->assertSame(CollectorType::Summary, $collector->type); + $this->assertSame([], $collector->toArray()['buckets']); + } + public function testWithNamespace(): void { $collector = Collector::counter();