Most explanations of APM stop at the dashboard. But the part that decides whether monitoring costs you latency, survives a vendor outage, or quietly leaks memory on Octane is the agent, the component that actually sits in or beside your app collecting the data. It's the least glamorous piece and the one whose design you'll feel the most.
Three agent architectures
1. In-process (library)
A composer package that registers inside your Laravel app. Captures telemetry inside the PHP process during the request, then either writes it to storage directly (Telescope writes to your database) or sends it to the vendor over HTTP. Examples: Laravel Telescope, Sentry's default PHP SDK, Flare's SDK, Inspector.dev's Laravel package.
Pros: easy install (composer require + done), no extra process to supervise, works on any host.
Cons: overhead hits every request and grows with what's captured, HTTP shipping can block on vendor outages if not queued, and state can build up on persistent workers like Octane unless the SDK resets it.
2. Out-of-process (daemon)
A separate long-running process (usually a ReactPHP daemon or system service) that buffers telemetry from your Laravel app and ships it to the dashboard asynchronously. Examples: NightOwl's agent, Laravel Nightwatch package's agent, Datadog's Lambda Extension.
Pros: little work on the request path, crash isolation (agent crash doesn't take down your app), graceful handling of vendor outages (buffers telemetry locally).
Cons: need to supervise the extra process (Supervisor, systemd, Forge daemons), slightly more setup, doesn't fit serverless like Lambda without a Lambda Extension variant.
3. System extension (PHP extension)
A compiled PHP extension that hooks into the runtime at a low level. Can capture data userland PHP can't see: opcache stats, runtime-internal timings, low-overhead stack sampling. Examples: New Relic PHP agent, Tideways PHP extension.
Pros: maximum data richness, often lowest per-request overhead, captures things composer packages can't.
Cons: requires root access to install, has to be built for your exact PHP version (a PHP upgrade waits on a compatible release), ties you to the vendor.
How NightOwl's agent works
Laravel request flow
├── Request arrives at PHP-FPM / Octane worker
├── Nightwatch package observes events (queries, jobs, exceptions, etc.)
├── Worker returns response to user ← latency budget ends here
├── Nightwatch sends the payload to a local TCP socket (port 2407)
│
└── NightOwl agent (separate ReactPHP process)
├── Receives payloads asynchronously from all app workers
├── Buffers them in a local SQLite file (WAL mode)
├── Batch-writes to your PostgreSQL via COPY protocol
└── Retries on transient failures The app worker only serializes the payload and writes it to the socket, after the response has gone out. All heavy lifting (validation, batching, PostgreSQL COPY) happens in the separate agent process. A single agent instance has been benchmarked at 13,400 payloads/s of ingest; writing to PostgreSQL is a separate stage and runs slower.
Why architecture matters for Octane
In Octane, a worker stays alive across many requests (500 by default before Octane recycles it). An in-process agent that doesn't reset its state (event buffers, retry queues, observer registrations) between requests carries it across every request the worker handles, and memory grows until the worker is recycled or runs out.
Out-of-process agents sidestep this: the agent's state is in its own process. Nightwatch opens a connection to the agent for each payload, so the Laravel worker holds no telemetry between requests. This is why NightOwl's architecture is Octane-native and why some SDK-based APMs require extra work to be Octane-safe.