Skip to content

Commit 98af07f

Browse files
Laravel: hook Foundation\Application.
1 parent 1deb2b4 commit 98af07f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/Instrumentation/Laravel/src/Hooks/Illuminate/Foundation/Application.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,38 @@
66

77
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
88
use Illuminate\Foundation\Application as FoundationalApplication;
9-
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\LaravelHook;
10-
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\LaravelHookTrait;
9+
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
10+
use OpenTelemetry\API\Logs\LoggerInterface;
11+
use OpenTelemetry\API\Metrics\MeterInterface;
12+
use OpenTelemetry\API\Trace\TracerInterface;
13+
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Hook;
14+
use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelConfiguration;
1115
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\CacheWatcher;
1216
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\ClientRequestWatcher;
1317
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\ExceptionWatcher;
1418
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\LogWatcher;
1519
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\QueryWatcher;
1620
use OpenTelemetry\Contrib\Instrumentation\Laravel\Watchers\Watcher;
17-
use function OpenTelemetry\Instrumentation\hook;
1821
use Throwable;
1922

20-
class Application implements LaravelHook
23+
class Application implements Hook
2124
{
22-
use LaravelHookTrait;
23-
24-
public function instrument(): void
25-
{
26-
hook(
25+
public function instrument(
26+
HookManager $hookManager,
27+
LaravelConfiguration $configuration,
28+
LoggerInterface $logger,
29+
MeterInterface $meter,
30+
TracerInterface $tracer,
31+
): void {
32+
$hookManager->hook(
2733
FoundationalApplication::class,
2834
'__construct',
29-
post: function (FoundationalApplication $application, array $params, mixed $returnValue, ?Throwable $exception) {
35+
postHook: function (FoundationalApplication $application, array $params, mixed $returnValue, ?Throwable $exception) use ($tracer) {
3036
$this->registerWatchers($application, new CacheWatcher());
31-
$this->registerWatchers($application, new ClientRequestWatcher($this->instrumentation));
37+
$this->registerWatchers($application, new ClientRequestWatcher($tracer));
3238
$this->registerWatchers($application, new ExceptionWatcher());
3339
$this->registerWatchers($application, new LogWatcher());
34-
$this->registerWatchers($application, new QueryWatcher($this->instrumentation));
40+
$this->registerWatchers($application, new QueryWatcher($tracer));
3541
},
3642
);
3743
}

0 commit comments

Comments
 (0)