8
8
use Illuminate \Contracts \Http \Kernel ;
9
9
use Illuminate \Support \ServiceProvider ;
10
10
use OpenTelemetry \API \Trace \SpanKind ;
11
+ use OpenTelemetry \Context \Context ;
11
12
use OpenTelemetry \SDK \Common \Time \ClockFactory ;
12
13
use Overtrue \LaravelOpenTelemetry \Middlewares \MeasureRequest ;
13
14
use Overtrue \LaravelOpenTelemetry \Support \CarbonClock ;
@@ -38,10 +39,6 @@ public function boot(): void
38
39
if (config ('otle.automatically_trace_requests ' )) {
39
40
$ this ->injectHttpMiddleware (app (Kernel::class));
40
41
}
41
-
42
- if ($ this ->app ->runningInConsole () && config ('otle.automatically_trace_cli ' )) {
43
- $ this ->startMeasureConsole ();
44
- }
45
42
}
46
43
47
44
public function register (): void
@@ -67,6 +64,10 @@ public function register(): void
67
64
$ this ->app ->singleton (TracerManager::class, function ($ app ) {
68
65
return new TracerManager ($ app );
69
66
});
67
+
68
+ if ($ this ->app ->runningInConsole () && config ('otle.automatically_trace_cli ' )) {
69
+ $ this ->startMeasureConsole ();
70
+ }
70
71
}
71
72
72
73
protected function injectLogConfig (): void
@@ -107,6 +108,7 @@ public function startMeasureConsole(): void
107
108
$ span = Facades \Measure::span ('artisan ' )
108
109
->setSpanKind (SpanKind::KIND_SERVER )
109
110
->start ();
111
+ $ span ->storeInContext (Context::getCurrent ());
110
112
$ scope = $ span ->activate ();
111
113
112
114
$ this ->app ->terminating (function () use ($ span , $ scope ) {
0 commit comments