Skip to content

Commit c1737e1

Browse files
authored
Be less restrictive when autoloading instrumentation libraries (#133)
* Be less restrictive when autoloading instrumentation libraries Emit a warning through trigger_error instead of using an assert. This will allow one to use the libraries in environments where the extension might not be available. However in case of issues, it will be clear through logs why code might not be instrumented * Implement early return style
1 parent 5542bc4 commit c1737e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

_register.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
declare(strict_types=1);
44

5-
assert(extension_loaded('otel_instrumentation'));
5+
use OpenTelemetry\Contrib\Instrumentation\Symfony\SymfonyInstrumentation;
66

7-
\OpenTelemetry\Contrib\Instrumentation\Symfony\SymfonyInstrumentation::register();
7+
if (extension_loaded('otel_instrumentation') === false) {
8+
trigger_error('The otel_instrumentation extension must be loaded in order to autoload the OpenTelemetry Laravel auto-instrumentation', E_USER_WARNING);
9+
10+
return;
11+
}
12+
13+
SymfonyInstrumentation::register();

0 commit comments

Comments
 (0)