[ GLOSSARY ]

What is an APM agent?

QUICK ANSWER

What is an APM agent and why does its architecture matter?

An APM agent is the code or process that collects telemetry from your application and ships it to a dashboard. In-process agents run inside your app's runtime — simple to install, but overhead hits every request. Out-of-process agents run as separate daemons (like NightOwl's ReactPHP agent) — minimal request-path overhead but slightly more deployment complexity. For production Laravel, out-of-process is the gold standard, especially on Octane where in-process agents accumulate memory across requests.

Updated · 2026-04-13

Three agent architectures

1. In-process (library)

A composer package that registers inside your Laravel app. Captures telemetry synchronously during the request and ships it via HTTP after the response. 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 (typically 5-50ms), HTTP shipping can block on vendor outages if not queued, accumulates memory on persistent workers like Octane.

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: sub-1ms request-path overhead, 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, zero-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 match your PHP version exactly (breaks on upgrades), ties you to the vendor.

How NightOwl's agent works

text
Laravel request flow
├── Request arrives at PHP-FPM / Octane worker
├── Nightwatch package observes events (queries, jobs, exceptions, etc.)
├── Events serialized to a local TCP socket (port 2407)
├── Worker returns response to user  ← latency budget ends here
│
└── NightOwl agent (separate ReactPHP process)
    ├── Receives events asynchronously from all app workers
    ├── Buffers in-memory queue
    ├── Batch-writes to your PostgreSQL via COPY protocol
    └── Retries on transient failures

Request-path overhead: serialize + socket write = under 1ms. All heavy lifting (validation, batching, PostgreSQL COPY) happens in the separate agent process. Benchmarked at 13,400 payloads/s single-instance.

Why architecture matters for Octane

In Octane, a worker handles thousands of requests without dying. In-process agents accumulate state — event buffers, retry queues, observer registrations — across every request the worker handles. Memory grows; eventually the worker OOMs or slows.

Out-of-process agents immunize you: the agent's state is in its own process; the Laravel worker holds nothing across requests beyond a socket connection. This is why NightOwl's architecture is Octane-native and why some SDK-based APMs require extra work to be Octane-safe.

Frequently asked questions

What is an APM agent?

An APM agent is the code or process that collects telemetry from your application and ships it to a dashboard. Can be a library compiled into your app (in-process agent), a sidecar process running alongside (out-of-process agent), or a system-level extension (PHP extension, Lambda Layer). The agent's architecture meaningfully affects performance, reliability, and deployment complexity.

What's the difference between an in-process and out-of-process agent?

In-process agents run inside your application's runtime — same PHP process, same memory space. Low deployment complexity, but instrumentation overhead affects every request. Out-of-process agents run as a separate process (ReactPHP daemon, system service, sidecar container). Higher deployment complexity, but zero request-path overhead because the heavy work happens asynchronously.

Which APM agent architecture is best for Laravel?

For production Laravel, out-of-process agents (like NightOwl's ReactPHP-based agent or the Nightwatch package's similar architecture) are the gold standard — they add under 1ms per request. In-process agents (Telescope, Sentry's PHP SDK in non-async mode) are simpler to install but add 5-50ms per request depending on what's captured. For Octane, out-of-process is mandatory because in-process agents accumulate memory across requests.

Do I need to install a system extension for APM?

Usually not for Laravel. Some vendors ship PHP extensions (New Relic, Tideways) that hook into the PHP runtime at a low level — maximum data richness, but requires server root access and extension compatibility per PHP version. Most modern Laravel APMs (NightOwl, Nightwatch, Sentry, Inspector) use pure-PHP agents that install via composer.

How does the APM agent avoid slowing down my Laravel requests?

Three techniques, usually combined. Sampling — record only a percentage of traces. Buffering — queue telemetry in memory, flush in batches. Out-of-process shipping — hand telemetry to a separate process via a socket or queue; your request returns immediately. NightOwl and Nightwatch Cloud use all three.

What does the APM agent actually collect?

Depends on the product. For Laravel: HTTP requests (route, duration, status), exceptions (class, stack, context), DB queries (SQL, duration, bindings), queue jobs (class, duration, status), scheduled tasks, cache operations, outgoing HTTP calls, mail dispatches, notifications, log records, and any custom spans you add. Each is a separate 'watcher' that can be independently enabled or disabled.

Can I run multiple APM agents?

Yes, they don't conflict. Common pattern: Sentry for errors, NightOwl for performance and Laravel-specific watchers, Datadog for infrastructure. Each agent registers its own handlers. Overhead compounds, though — three agents each adding 2ms means 6ms per request. Prefer one agent that covers what you need.

PRICING

Flat pricing. No event caps. No per-seat fees.

14-day free trial, no credit card. Your PostgreSQL, your data.

HOBBY

$5 /month

1 app · 14 days lookback · all Laravel events

TEAM

$15 /month

Up to 3 connected apps · unlimited environments · all Laravel events

AGENCY

$69 /month

Unlimited apps · unlimited agent instances · same flat rate at any traffic