Skip to content

Commit c1ed471

Browse files
Laravel: register with SPI ServiceLoader in case SPI plugin is not allowed.
1 parent bb09763 commit c1ed471

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Nevay\SPI\ServiceLoader;
6+
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\Instrumentation;
7+
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks;
8+
use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelInstrumentation;
9+
10+
// In case the `tbachert/spi` plugin has not been allowed in composer allow-plugins (root-level).
11+
ServiceLoader::register(Instrumentation::class, LaravelInstrumentation::class);
12+
13+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Console\Command::class);
14+
15+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Console\Kernel::class);
16+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Http\Kernel::class);
17+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Queue\Queue::class);
18+
19+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Foundation\Console\ServeCommand::class);
20+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Foundation\Application::class);
21+
22+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\Queue::class);
23+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\SyncQueue::class);
24+
ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\Worker::class);

src/Instrumentation/Laravel/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"autoload": {
3333
"psr-4": {
3434
"OpenTelemetry\\Contrib\\Instrumentation\\Laravel\\": "src/"
35-
}
35+
},
36+
"files": [
37+
"_register.php"
38+
]
3639
},
3740
"autoload-dev": {
3841
"psr-4": {

0 commit comments

Comments
 (0)