Skip to content

Commit

Permalink
Laravel Instrumentation:
Browse files Browse the repository at this point in the history
Hook into `\Illuminate\Contracts\Foundation\Application`.
Allows for watcher registration in console Kernel contexts.
  • Loading branch information
ChrisLightfootWild committed Aug 11, 2023
1 parent 33b3624 commit 347a001
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/Instrumentation/Laravel/src/LaravelInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace OpenTelemetry\Contrib\Instrumentation\Laravel;

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Http\Kernel;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
Expand Down Expand Up @@ -93,19 +93,15 @@ public static function register(): void
}
);
hook(
Kernel::class,
Application::class,
'__construct',
pre: static function (Kernel $kernel, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation) {
$app = $params[0];
$app->booted(static function (Application $app) use ($instrumentation) {
self::registerWatchers($app, new ClientRequestWatcher($instrumentation));
self::registerWatchers($app, new ExceptionWatcher());
self::registerWatchers($app, new CacheWatcher());
self::registerWatchers($app, new LogWatcher());
self::registerWatchers($app, new QueryWatcher($instrumentation));
});
},
post: null
post: static function (Application $application, array $params, mixed $returnValue, ?Throwable $exception) use ($instrumentation) {
self::registerWatchers($application, new ClientRequestWatcher($instrumentation));
self::registerWatchers($application, new ExceptionWatcher());
self::registerWatchers($application, new CacheWatcher());
self::registerWatchers($application, new LogWatcher());
self::registerWatchers($application, new QueryWatcher($instrumentation));
}
);
}

Expand Down

0 comments on commit 347a001

Please sign in to comment.