Skip to content

Add Nightwatch::digest to proactively transmit events to the agent#330

Open
timacdonald wants to merge 1 commit into1.xfrom
digest
Open

Add Nightwatch::digest to proactively transmit events to the agent#330
timacdonald wants to merge 1 commit into1.xfrom
digest

Conversation

@timacdonald
Copy link
Member

@timacdonald timacdonald commented Feb 19, 2026

Add a public facing Nightwatch::digest method that mimics the Pulse::digest method. It proactively transmits any pending events while also respecting sampling, if it has been configured.

This is useful in long running processes where you want to dynamically control when an ingest occurs.

Imagine:

  • you are running two processes for redundancy
  • only a single process does the work
  • a cache lock is used to determine which process does the work

In this scenario, one process may do a bunch of work building up events and then the other process might step in and start doing a bunch of work. The events from process the first process may never be transmitted, as they are only transmitted once they reach the event threshold, which defaults to 500 events.

This PR allows fine-grained control over when events are ingested, e.g.,

use Laravel\Nightwatch\Facades\Nightwatch;

if (previously_was_main_process()) {
    // Proactively transmit events to the agent
    // rather than waiting to reach the event
    // threshold.
    Nightwatch::digest();
}

@timacdonald timacdonald changed the title Add public digest method Add Nightwatch::digest to proactively transmit events to the agent Feb 19, 2026
*/
public function digest(): void
{
$this->finishExecution();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing the finishExecution method doesn't make sense from a naming perspective. This isn't going to be used at the end of an execution, but mid-way through.

Nightwatch::digest() is much nicer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments