@@ -55,8 +55,6 @@ trait CapturesState
5555
5656 private bool $ paused = false ;
5757
58- private bool $ waitingForJob = false ;
59-
6058 /**
6159 * @var WeakMap<Route, bool>
6260 */
@@ -75,7 +73,7 @@ public function sample(float $rate = 1.0): void
7573
7674 $ this ->sampling = $ sample ;
7775
78- $ this ->ingest ->shouldDigest ($ sample );
76+ $ this ->ingest ->shouldDigestWhenBufferIsFull ($ sample );
7977
8078 Compatibility::addSamplingToContext ($ sample );
8179 }
@@ -173,7 +171,9 @@ public function report(Throwable $e, ?bool $handled = null): void
173171
174172 try {
175173 if ($ e instanceof FatalError) {
176- $ this ->ingest ->writeNow ($ this ->sensor ->fatalError ($ e ));
174+ if ($ this ->sampling ) {
175+ $ this ->ingest ->writeNow ($ this ->sensor ->fatalError ($ e ));
176+ }
177177 } else {
178178 $ this ->ingest ->write ($ this ->sensor ->exception ($ e , $ handled ));
179179 }
@@ -458,9 +458,9 @@ public function attachMiddlewareToRoute(Route $route): void
458458 /**
459459 * @internal
460460 */
461- public function waitForJob (): void
461+ public function waitForExecution (): void
462462 {
463- $ this ->waitingForJob = true ;
463+ $ this ->dontSample () ;
464464 }
465465
466466 /**
@@ -469,7 +469,7 @@ public function waitForJob(): void
469469 public function configureForJobs (): void
470470 {
471471 $ this ->executionState ->source = 'job ' ;
472- $ this ->waitingForJob = true ;
472+ $ this ->waitForExecution () ;
473473 }
474474
475475 /**
@@ -496,7 +496,6 @@ public function prepareForJob(Job $job): void
496496 Compatibility::getSamplingFromContext (default: true ) ? 1.0 : 0.0
497497 );
498498
499- $ this ->waitingForJob = false ;
500499 $ this ->executionState ->timestamp = $ this ->clock ->microtime ();
501500 $ this ->executionState ->setId ($ this ->uuid ->make ());
502501 $ this ->executionState ->executionPreview = Str::tinyText ($ job ->resolveName ());
@@ -558,6 +557,7 @@ public function command(InputInterface $input, int $status): void
558557 public function configureForScheduledTasks (): void
559558 {
560559 $ this ->executionState ->source = 'schedule ' ;
560+ $ this ->waitForExecution ();
561561 }
562562
563563 /**
@@ -579,6 +579,7 @@ public function prepareForNextScheduledTask(): void
579579 $ this ->executionState ->trace = $ trace ;
580580 $ this ->executionState ->setId ($ trace );
581581 $ this ->executionState ->timestamp = $ this ->clock ->microtime ();
582+ $ this ->sample ();
582583 }
583584
584585 /**
0 commit comments