Skip to content

Commit

Permalink
Adding 'all' as an option for disabling auto instrumentations (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaojacome committed Jan 24, 2024
1 parent 810aa2f commit f2ab3c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/SDK/Sdk.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

class Sdk
{
private const OTEL_PHP_DISABLED_INSTRUMENTATIONS_ALL = 'all';

private TracerProviderInterface $tracerProvider;
private MeterProviderInterface $meterProvider;
private LoggerProviderInterface $loggerProvider;
Expand Down Expand Up @@ -40,7 +42,9 @@ public static function isDisabled(): bool
*/
public static function isInstrumentationDisabled(string $name): bool
{
return in_array($name, Configuration::getList(Variables::OTEL_PHP_DISABLED_INSTRUMENTATIONS));
$disabledInstrumentations = Configuration::getList(Variables::OTEL_PHP_DISABLED_INSTRUMENTATIONS);

return [self::OTEL_PHP_DISABLED_INSTRUMENTATIONS_ALL] === $disabledInstrumentations || in_array($name, $disabledInstrumentations);
}

public static function builder(): SdkBuilder
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/SDK/SdkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static function instrumentationDisabledProvider(): array
['foo,bar', 'bar', true],
['', 'foo', false],
['foo', 'foo', true],
['all', 'foo', true],
['all,bar', 'foo', false],
['all,foo', 'foo', true],
];
}

Expand Down

0 comments on commit f2ab3c5

Please sign in to comment.