From 0ba41f540b60c84773694e6f41d57df34960256a Mon Sep 17 00:00:00 2001 From: Christian Daguerre Date: Wed, 2 Oct 2024 19:08:40 +0200 Subject: [PATCH 1/2] chore: add isEnabled --- src/Tracing/Tracer.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Tracing/Tracer.php b/src/Tracing/Tracer.php index eeb7357..db838fb 100644 --- a/src/Tracing/Tracer.php +++ b/src/Tracing/Tracer.php @@ -37,4 +37,9 @@ public function spanBuilder(string $spanName): SpanBuilderInterface { return $this->decorated->spanBuilder($spanName); } + + public function isEnabled(): bool + { + return $this->decorated->isEnabled(); + } } From 8c54cb373eb98318a7340b52d71a27ab20448876 Mon Sep 17 00:00:00 2001 From: Christian Daguerre Date: Wed, 2 Oct 2024 19:28:02 +0200 Subject: [PATCH 2/2] chore: add missing methods --- composer.json | 3 ++- src/Metrics/CounterAdapter.php | 5 +++++ src/Metrics/HistogramAdapter.php | 5 +++++ src/Metrics/Meter.php | 6 ++++++ src/Metrics/UpDownCounterAdapter.php | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b92b07b..f7e3248 100644 --- a/composer.json +++ b/composer.json @@ -61,7 +61,8 @@ "minimum-stability": "dev", "prefer-stable": true, "allow-plugins": { - "php-http/discovery": false + "php-http/discovery": false, + "tbachert/spi": false } }, "extra": { diff --git a/src/Metrics/CounterAdapter.php b/src/Metrics/CounterAdapter.php index bc19188..05a2aff 100644 --- a/src/Metrics/CounterAdapter.php +++ b/src/Metrics/CounterAdapter.php @@ -42,4 +42,9 @@ public function add($amount, iterable $attributes = [], $context = null): void $counter->incBy($amount, $labelValues); } + + public function isEnabled(): bool + { + return true; + } } diff --git a/src/Metrics/HistogramAdapter.php b/src/Metrics/HistogramAdapter.php index d1bc108..7e33b09 100644 --- a/src/Metrics/HistogramAdapter.php +++ b/src/Metrics/HistogramAdapter.php @@ -41,4 +41,9 @@ public function record($amount, iterable $attributes = [], $context = null): voi ); $histogram->observe($amount, $labelValues); } + + public function isEnabled(): bool + { + return true; + } } diff --git a/src/Metrics/Meter.php b/src/Metrics/Meter.php index c7fbca9..5bbc53c 100644 --- a/src/Metrics/Meter.php +++ b/src/Metrics/Meter.php @@ -9,6 +9,7 @@ use OpenTelemetry\API\Metrics\AsynchronousInstrument; use OpenTelemetry\API\Metrics\CounterInterface; +use OpenTelemetry\API\Metrics\GaugeInterface; use OpenTelemetry\API\Metrics\HistogramInterface; use OpenTelemetry\API\Metrics\MeterInterface; use OpenTelemetry\API\Metrics\ObservableCallbackInterface; @@ -79,6 +80,11 @@ public function createHistogram(string $name, string|null $unit = null, string|n return new HistogramAdapter($name, $description ?: '', $this->collectorRegistry); } + public function createGauge(string $name, string|null $unit = null, string|null $description = null, array $advisory = []): GaugeInterface + { + throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__)); + } + /** * Creates an `ObservableGauge`. * diff --git a/src/Metrics/UpDownCounterAdapter.php b/src/Metrics/UpDownCounterAdapter.php index ffd31d1..5a9e7f0 100644 --- a/src/Metrics/UpDownCounterAdapter.php +++ b/src/Metrics/UpDownCounterAdapter.php @@ -45,4 +45,9 @@ public function add($amount, iterable $attributes = [], $context = null): void $gauge->decBy(abs($amount), $labelValues); } } + + public function isEnabled(): bool + { + return true; + } }