summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria')
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/AllCriteria.php33
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentNameCriteria.php28
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentTypeCriteria.php29
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeNameCriteria.php24
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeSchemaUrlCriteria.php24
-rw-r--r--vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeVersionCriteria.php24
6 files changed, 162 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/AllCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/AllCriteria.php
new file mode 100644
index 000000000..438297324
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/AllCriteria.php
@@ -0,0 +1,33 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+
+final class AllCriteria implements SelectionCriteriaInterface
+{
+ private iterable $criteria;
+
+ /**
+ * @param iterable<SelectionCriteriaInterface> $criteria
+ */
+ public function __construct(iterable $criteria)
+ {
+ $this->criteria = $criteria;
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ foreach ($this->criteria as $criterion) {
+ if (!$criterion->accepts($instrument, $instrumentationScope)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentNameCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentNameCriteria.php
new file mode 100644
index 000000000..ed6034755
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentNameCriteria.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+use function preg_match;
+use function preg_quote;
+use function sprintf;
+use function strtr;
+
+final class InstrumentNameCriteria implements SelectionCriteriaInterface
+{
+ private string $pattern;
+
+ public function __construct(string $name)
+ {
+ $this->pattern = sprintf('/^%s$/', strtr(preg_quote($name, '/'), ['\\?' => '.', '\\*' => '.*']));
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ return (bool) preg_match($this->pattern, $instrument->name);
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentTypeCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentTypeCriteria.php
new file mode 100644
index 000000000..46a88def0
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentTypeCriteria.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use function in_array;
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\InstrumentType;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+
+final class InstrumentTypeCriteria implements SelectionCriteriaInterface
+{
+ private array $instrumentTypes;
+
+ /**
+ * @param string|InstrumentType|string[]|InstrumentType[] $instrumentType
+ */
+ public function __construct($instrumentType)
+ {
+ $this->instrumentTypes = (array) $instrumentType;
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ return in_array($instrument->type, $this->instrumentTypes, true);
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeNameCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeNameCriteria.php
new file mode 100644
index 000000000..201d1a7b2
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeNameCriteria.php
@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+
+final class InstrumentationScopeNameCriteria implements SelectionCriteriaInterface
+{
+ private string $name;
+
+ public function __construct(string $name)
+ {
+ $this->name = $name;
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ return $this->name === $instrumentationScope->getName();
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeSchemaUrlCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeSchemaUrlCriteria.php
new file mode 100644
index 000000000..a11a1d589
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeSchemaUrlCriteria.php
@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+
+final class InstrumentationScopeSchemaUrlCriteria implements SelectionCriteriaInterface
+{
+ private ?string $schemaUrl;
+
+ public function __construct(?string $schemaUrl)
+ {
+ $this->schemaUrl = $schemaUrl;
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ return $this->schemaUrl === $instrumentationScope->getSchemaUrl();
+ }
+}
diff --git a/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeVersionCriteria.php b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeVersionCriteria.php
new file mode 100644
index 000000000..37d180f99
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Metrics/View/SelectionCriteria/InstrumentationScopeVersionCriteria.php
@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Metrics\View\SelectionCriteria;
+
+use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface;
+use OpenTelemetry\SDK\Metrics\Instrument;
+use OpenTelemetry\SDK\Metrics\View\SelectionCriteriaInterface;
+
+final class InstrumentationScopeVersionCriteria implements SelectionCriteriaInterface
+{
+ private ?string $version;
+
+ public function __construct(?string $version)
+ {
+ $this->version = $version;
+ }
+
+ public function accepts(Instrument $instrument, InstrumentationScopeInterface $instrumentationScope): bool
+ {
+ return $this->version === $instrumentationScope->getVersion();
+ }
+}