diff options
Diffstat (limited to 'vendor/open-telemetry/api/Metrics')
19 files changed, 517 insertions, 0 deletions
diff --git a/vendor/open-telemetry/api/Metrics/CounterInterface.php b/vendor/open-telemetry/api/Metrics/CounterInterface.php new file mode 100644 index 000000000..f0da706e1 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/CounterInterface.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +use OpenTelemetry\Context\ContextInterface; + +interface CounterInterface +{ + + /** + * @param float|int $amount non-negative amount to increment by + * @param iterable<non-empty-string, string|bool|float|int|array|null> $attributes + * attributes of the data point + * @param ContextInterface|false|null $context execution context + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#add + */ + public function add($amount, iterable $attributes = [], $context = null): void; +} diff --git a/vendor/open-telemetry/api/Metrics/HistogramInterface.php b/vendor/open-telemetry/api/Metrics/HistogramInterface.php new file mode 100644 index 000000000..22ddd1f3c --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/HistogramInterface.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +use OpenTelemetry\Context\ContextInterface; + +interface HistogramInterface +{ + + /** + * @param float|int $amount non-negative amount to record + * @param iterable<non-empty-string, string|bool|float|int|array|null> $attributes + * attributes of the data point + * @param ContextInterface|false|null $context execution context + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#record + */ + public function record($amount, iterable $attributes = [], $context = null): void; +} diff --git a/vendor/open-telemetry/api/Metrics/MeterInterface.php b/vendor/open-telemetry/api/Metrics/MeterInterface.php new file mode 100644 index 000000000..6e06d9085 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/MeterInterface.php @@ -0,0 +1,111 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface MeterInterface +{ + + /** + * Creates a `Counter`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @return CounterInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#counter-creation + */ + public function createCounter( + string $name, + ?string $unit = null, + ?string $description = null + ): CounterInterface; + + /** + * Creates an `ObservableCounter`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @param callable ...$callbacks responsible for reporting measurements + * @return ObservableCounterInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#asynchronous-counter-creation + */ + public function createObservableCounter( + string $name, + ?string $unit = null, + ?string $description = null, + callable ...$callbacks + ): ObservableCounterInterface; + + /** + * Creates a `Histogram`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @return HistogramInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#histogram-creation + */ + public function createHistogram( + string $name, + ?string $unit = null, + ?string $description = null + ): HistogramInterface; + + /** + * Creates an `ObservableGauge`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @param callable ...$callbacks responsible for reporting measurements + * @return ObservableGaugeInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#asynchronous-gauge-creation + */ + public function createObservableGauge( + string $name, + ?string $unit = null, + ?string $description = null, + callable ...$callbacks + ): ObservableGaugeInterface; + + /** + * Creates an `UpDownCounter`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @return UpDownCounterInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#updowncounter-creation + */ + public function createUpDownCounter( + string $name, + ?string $unit = null, + ?string $description = null + ): UpDownCounterInterface; + + /** + * Creates an `ObservableUpDownCounter`. + * + * @param string $name name of the instrument + * @param string|null $unit unit of measure + * @param string|null $description description of the instrument + * @param callable ...$callbacks responsible for reporting measurements + * @return ObservableUpDownCounterInterface created instrument + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#asynchronous-updowncounter-creation + */ + public function createObservableUpDownCounter( + string $name, + ?string $unit = null, + ?string $description = null, + callable ...$callbacks + ): ObservableUpDownCounterInterface; +} diff --git a/vendor/open-telemetry/api/Metrics/MeterProviderInterface.php b/vendor/open-telemetry/api/Metrics/MeterProviderInterface.php new file mode 100644 index 000000000..f8fa07a2e --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/MeterProviderInterface.php @@ -0,0 +1,28 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface MeterProviderInterface +{ + + /** + * Returns a `Meter` for the given instrumentation scope. + * + * @param string $name name of the instrumentation scope + * @param string|null $version version of the instrumentation scope + * @param string|null $schemaUrl schema url to record in the emitted telemetry + * @param iterable<non-empty-string, string|bool|float|int|array|null> $attributes + * instrumentation scope attributes + * @return MeterInterface meter instance for the instrumentation scope + * + * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#get-a-meter + */ + public function getMeter( + string $name, + ?string $version = null, + ?string $schemaUrl = null, + iterable $attributes = [] + ): MeterInterface; +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopCounter.php b/vendor/open-telemetry/api/Metrics/Noop/NoopCounter.php new file mode 100644 index 000000000..d47fc2166 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopCounter.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\CounterInterface; + +/** + * @internal + */ +final class NoopCounter implements CounterInterface +{ + public function add($amount, iterable $attributes = [], $context = null): void + { + // no-op + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopHistogram.php b/vendor/open-telemetry/api/Metrics/Noop/NoopHistogram.php new file mode 100644 index 000000000..79f0e60ce --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopHistogram.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\HistogramInterface; + +/** + * @internal + */ +final class NoopHistogram implements HistogramInterface +{ + public function record($amount, iterable $attributes = [], $context = null): void + { + // no-op + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopMeter.php b/vendor/open-telemetry/api/Metrics/Noop/NoopMeter.php new file mode 100644 index 000000000..31e3bd35c --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopMeter.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\CounterInterface; +use OpenTelemetry\API\Metrics\HistogramInterface; +use OpenTelemetry\API\Metrics\MeterInterface; +use OpenTelemetry\API\Metrics\ObservableCounterInterface; +use OpenTelemetry\API\Metrics\ObservableGaugeInterface; +use OpenTelemetry\API\Metrics\ObservableUpDownCounterInterface; +use OpenTelemetry\API\Metrics\UpDownCounterInterface; + +final class NoopMeter implements MeterInterface +{ + public function createCounter(string $name, ?string $unit = null, ?string $description = null): CounterInterface + { + return new NoopCounter(); + } + + public function createObservableCounter(string $name, ?string $unit = null, ?string $description = null, callable ...$callbacks): ObservableCounterInterface + { + return new NoopObservableCounter(); + } + + public function createHistogram(string $name, ?string $unit = null, ?string $description = null): HistogramInterface + { + return new NoopHistogram(); + } + + public function createObservableGauge(string $name, ?string $unit = null, ?string $description = null, callable ...$callbacks): ObservableGaugeInterface + { + return new NoopObservableGauge(); + } + + public function createUpDownCounter(string $name, ?string $unit = null, ?string $description = null): UpDownCounterInterface + { + return new NoopUpDownCounter(); + } + + public function createObservableUpDownCounter(string $name, ?string $unit = null, ?string $description = null, callable ...$callbacks): ObservableUpDownCounterInterface + { + return new NoopObservableUpDownCounter(); + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopMeterProvider.php b/vendor/open-telemetry/api/Metrics/Noop/NoopMeterProvider.php new file mode 100644 index 000000000..b4b5810eb --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopMeterProvider.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\MeterInterface; +use OpenTelemetry\API\Metrics\MeterProviderInterface; + +final class NoopMeterProvider implements MeterProviderInterface +{ + public function getMeter( + string $name, + ?string $version = null, + ?string $schemaUrl = null, + iterable $attributes = [] + ): MeterInterface { + return new NoopMeter(); + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCallback.php b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCallback.php new file mode 100644 index 000000000..c933bd506 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCallback.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\ObservableCallbackInterface; + +/** + * @internal + */ +final class NoopObservableCallback implements ObservableCallbackInterface +{ + public function detach(): void + { + // no-op + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCounter.php b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCounter.php new file mode 100644 index 000000000..41e363201 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableCounter.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\ObservableCallbackInterface; +use OpenTelemetry\API\Metrics\ObservableCounterInterface; + +/** + * @internal + */ +final class NoopObservableCounter implements ObservableCounterInterface +{ + public function observe(callable $callback, bool $weaken = false): ObservableCallbackInterface + { + return new NoopObservableCallback(); + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopObservableGauge.php b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableGauge.php new file mode 100644 index 000000000..987a530c8 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableGauge.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\ObservableCallbackInterface; +use OpenTelemetry\API\Metrics\ObservableGaugeInterface; + +/** + * @internal + */ +final class NoopObservableGauge implements ObservableGaugeInterface +{ + public function observe(callable $callback, bool $weaken = false): ObservableCallbackInterface + { + return new NoopObservableCallback(); + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopObservableUpDownCounter.php b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableUpDownCounter.php new file mode 100644 index 000000000..65a2bb830 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopObservableUpDownCounter.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\ObservableCallbackInterface; +use OpenTelemetry\API\Metrics\ObservableUpDownCounterInterface; + +/** + * @internal + */ +final class NoopObservableUpDownCounter implements ObservableUpDownCounterInterface +{ + public function observe(callable $callback, bool $weaken = false): ObservableCallbackInterface + { + return new NoopObservableCallback(); + } +} diff --git a/vendor/open-telemetry/api/Metrics/Noop/NoopUpDownCounter.php b/vendor/open-telemetry/api/Metrics/Noop/NoopUpDownCounter.php new file mode 100644 index 000000000..e26140b7c --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/Noop/NoopUpDownCounter.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics\Noop; + +use OpenTelemetry\API\Metrics\UpDownCounterInterface; + +/** + * @internal + */ +final class NoopUpDownCounter implements UpDownCounterInterface +{ + public function add($amount, iterable $attributes = [], $context = null): void + { + // no-op + } +} diff --git a/vendor/open-telemetry/api/Metrics/ObservableCallbackInterface.php b/vendor/open-telemetry/api/Metrics/ObservableCallbackInterface.php new file mode 100644 index 000000000..a20e59666 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/ObservableCallbackInterface.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +/** + * An observed callback. + * + * Callbacks that are bound to an object are automatically detached when the + * `ObservableCallbackInterface` and the bound object are out of scope. + * This means that the `ObservableCallbackInterface` can be ignored if the + * observed callback should be bound to the lifetime of the object. + * ```php + * class Example { + * function __construct(MeterProviderInterface $meterProvider) { + * $meterProvider->getMeter('example') + * ->createObservableGauge('random') + * ->observe(fn(ObserverInterface $observer) + * => $observer->observe(rand(0, 10))); + * } + * } + * ``` + * Keeping a reference to the `ObservableCallbackInterface` within the bound + * object to gain a more fine-grained control over the life-time of the callback + * does not prevent garbage collection (but might require cycle collection). + * + * Unbound (static) callbacks must be detached manually using + * {@link ObservableCallbackInterface::detach()}. + * ```php + * class Example { + * private ObservableCallbackInterface $gauge; + * function __construct(MeterProviderInterface $meterProvider) { + * $this->gauge = $meterProvider->getMeter('example') + * ->createObservableGauge('random') + * ->observe(static fn(ObserverInterface $observer) + * => $observer->observe(rand(0, 10))); + * } + * function __destruct() { + * $this->gauge->detach(); + * } + * } + * ``` + * + * @see ObservableCounterInterface::observe() + * @see ObservableGaugeInterface::observe() + * @see ObservableUpDownCounterInterface::observe() + */ +interface ObservableCallbackInterface +{ + + /** + * Detaches the associated callback from the instrument. + */ + public function detach(): void; +} diff --git a/vendor/open-telemetry/api/Metrics/ObservableCounterInterface.php b/vendor/open-telemetry/api/Metrics/ObservableCounterInterface.php new file mode 100644 index 000000000..feb1ed439 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/ObservableCounterInterface.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface ObservableCounterInterface +{ + + /** + * @param callable(ObserverInterface): void $callback function responsible for + * reporting the measurements (as absolute values) + * @return ObservableCallbackInterface token to detach callback + */ + public function observe(callable $callback): ObservableCallbackInterface; +} diff --git a/vendor/open-telemetry/api/Metrics/ObservableGaugeInterface.php b/vendor/open-telemetry/api/Metrics/ObservableGaugeInterface.php new file mode 100644 index 000000000..afe59a777 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/ObservableGaugeInterface.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface ObservableGaugeInterface +{ + + /** + * @param callable(ObserverInterface): void $callback function responsible for + * reporting the measurements + * @return ObservableCallbackInterface token to detach callback + */ + public function observe(callable $callback): ObservableCallbackInterface; +} diff --git a/vendor/open-telemetry/api/Metrics/ObservableUpDownCounterInterface.php b/vendor/open-telemetry/api/Metrics/ObservableUpDownCounterInterface.php new file mode 100644 index 000000000..79548dec6 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/ObservableUpDownCounterInterface.php @@ -0,0 +1,16 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface ObservableUpDownCounterInterface +{ + + /** + * @param callable(ObserverInterface): void $callback function responsible for + * reporting the measurements (as absolute values) + * @return ObservableCallbackInterface token to detach callback + */ + public function observe(callable $callback): ObservableCallbackInterface; +} diff --git a/vendor/open-telemetry/api/Metrics/ObserverInterface.php b/vendor/open-telemetry/api/Metrics/ObserverInterface.php new file mode 100644 index 000000000..36e0ea791 --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/ObserverInterface.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +interface ObserverInterface +{ + + /** + * Records the given absolute datapoint. + * + * @param float|int $amount observed amount + * @param iterable<non-empty-string, string|bool|float|int|array|null> $attributes + * attributes of the data point + */ + public function observe($amount, iterable $attributes = []): void; +} diff --git a/vendor/open-telemetry/api/Metrics/UpDownCounterInterface.php b/vendor/open-telemetry/api/Metrics/UpDownCounterInterface.php new file mode 100644 index 000000000..f1f808fdb --- /dev/null +++ b/vendor/open-telemetry/api/Metrics/UpDownCounterInterface.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +namespace OpenTelemetry\API\Metrics; + +use OpenTelemetry\Context\ContextInterface; + +interface UpDownCounterInterface +{ + + /** + * @param float|int $amount amount to increment / decrement by + * @param iterable<non-empty-string, string|bool|float|int|array|null> $attributes + * attributes of the data point + * @param ContextInterface|false|null $context execution context + */ + public function add($amount, iterable $attributes = [], $context = null): void; +} |