77use Illuminate \Contracts \Http \Kernel as KernelContract ;
88use Illuminate \Http \Request ;
99use Illuminate \Routing \Route ;
10- use OpenTelemetry \API \Globals ;
1110use OpenTelemetry \API \Instrumentation \AutoInstrumentation \Context as InstrumentationContext ;
1211use OpenTelemetry \API \Instrumentation \AutoInstrumentation \HookManagerInterface ;
1312use OpenTelemetry \API \Trace \Span ;
1615use OpenTelemetry \API \Trace \StatusCode ;
1716use OpenTelemetry \API \Trace \TracerInterface ;
1817use OpenTelemetry \Context \Context ;
18+ use OpenTelemetry \Context \Propagation \TextMapPropagatorInterface ;
1919use OpenTelemetry \Contrib \Instrumentation \Laravel \Hooks \Hook ;
2020use OpenTelemetry \Contrib \Instrumentation \Laravel \Hooks \PostHookTrait ;
2121use OpenTelemetry \Contrib \Instrumentation \Laravel \LaravelInstrumentation ;
@@ -40,15 +40,18 @@ public function instrument(
4040 schemaUrl: Version::VERSION_1_24_0 ->url (),
4141 );
4242
43- $ this ->hookHandle ($ hookManager , $ tracer );
43+ $ this ->hookHandle ($ hookManager , $ tracer, $ context -> propagator );
4444 }
4545
46- protected function hookHandle (HookManagerInterface $ hookManager , TracerInterface $ tracer ): void
47- {
46+ protected function hookHandle (
47+ HookManagerInterface $ hookManager ,
48+ TracerInterface $ tracer ,
49+ TextMapPropagatorInterface $ propagator ,
50+ ): void {
4851 $ hookManager ->hook (
4952 KernelContract::class,
5053 'handle ' ,
51- preHook: function (KernelContract $ kernel , array $ params , string $ class , string $ function , ?string $ filename , ?int $ lineno ) use ($ tracer ) {
54+ preHook: function (KernelContract $ kernel , array $ params , string $ class , string $ function , ?string $ filename , ?int $ lineno ) use ($ tracer, $ propagator ) {
5255 $ request = ($ params [0 ] instanceof Request) ? $ params [0 ] : null ;
5356 /** @psalm-suppress ArgumentTypeCoercion */
5457 $ builder = $ tracer
@@ -61,7 +64,7 @@ protected function hookHandle(HookManagerInterface $hookManager, TracerInterface
6164 $ parent = Context::getCurrent ();
6265 if ($ request ) {
6366 /** @phan-suppress-next-line PhanAccessMethodInternal */
64- $ parent = Globals:: propagator () ->extract ($ request , HeadersPropagator::instance ());
67+ $ parent = $ propagator ->extract ($ request , HeadersPropagator::instance ());
6568 $ span = $ builder
6669 ->setParent ($ parent )
6770 ->setAttribute (TraceAttributes::URL_FULL , $ request ->fullUrl ())
0 commit comments