Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add isEnabled #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"minimum-stability": "dev",
"prefer-stable": true,
"allow-plugins": {
"php-http/discovery": false
"php-http/discovery": false,
"tbachert/spi": false
}
},
"extra": {
Expand Down
5 changes: 5 additions & 0 deletions src/Metrics/CounterAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @param int $amount
* @param array{labels: array<string,mixed>} $attributes
*/
public function add($amount, iterable $attributes = [], $context = null): void

Check failure on line 26 in src/Metrics/CounterAdapter.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method Instrumentation\Metrics\CounterAdapter::add() has parameter $context with no type specified.

Check failure on line 26 in src/Metrics/CounterAdapter.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method Instrumentation\Metrics\CounterAdapter::add() has parameter $context with no type specified.
{
if (!\is_array($attributes)) {
return;
Expand All @@ -42,4 +42,9 @@

$counter->incBy($amount, $labelValues);
}

public function isEnabled(): bool
{
return true;
}
}
5 changes: 5 additions & 0 deletions src/Metrics/HistogramAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public function record($amount, iterable $attributes = [], $context = null): voi
);
$histogram->observe($amount, $labelValues);
}

public function isEnabled(): bool
{
return true;
}
}
6 changes: 6 additions & 0 deletions src/Metrics/Meter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,6 +80,11 @@
return new HistogramAdapter($name, $description ?: '', $this->collectorRegistry);
}

public function createGauge(string $name, string|null $unit = null, string|null $description = null, array $advisory = []): GaugeInterface

Check failure on line 83 in src/Metrics/Meter.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method Instrumentation\Metrics\Meter::createGauge() has parameter $advisory with no value type specified in iterable type array.

Check failure on line 83 in src/Metrics/Meter.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3)

Method Instrumentation\Metrics\Meter::createGauge() has parameter $advisory with no value type specified in iterable type array.
{
throw new \LogicException(\sprintf('Method %s is not implemented', __METHOD__));
}

/**
* Creates an `ObservableGauge`.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Metrics/UpDownCounterAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public function add($amount, iterable $attributes = [], $context = null): void
$gauge->decBy(abs($amount), $labelValues);
}
}

public function isEnabled(): bool
{
return true;
}
}
5 changes: 5 additions & 0 deletions src/Tracing/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public function spanBuilder(string $spanName): SpanBuilderInterface
{
return $this->decorated->spanBuilder($spanName);
}

public function isEnabled(): bool
{
return $this->decorated->isEnabled();
}
}
Loading