- Observation: The agent monitors your Laravel application, observing requests, commands, scheduled tasks, and all the events they trigger, e.g. queries, jobs, exceptions, etc.
- Sampling: For entry points (requests, commands, and scheduled tasks), sampling determines whether the entire trace should be collected based on configured sample rates. If a request is sampled, all related events within that request lifecycle are captured.
- Filtering: Once a trace has been selected for collection, filters can be applied with scalpel-like precision to exclude specific events based on criteria. Filters allow you to make granular decisions about individual events, determining whether they should be collected or excluded.
- Redaction: After data has passed through sampling and filtering gates, redaction methods allow you to manipulate the data being collected. This enables you to obfuscate sensitive information, modify user details, or add contextual information to records.
- Rate limiting: Finally, before a batch of events is transmitted, Nightwatch dispatches an event that allows you to enforce hard limits on the total number of events ingested.
Sampling
Sampling controls the rate at which entry points are collected. Entry points are the initial events that trigger a trace. These are requests, commands, and scheduled tasks. When an entry point is sampled in, the entire trace (including all related events like queries, jobs, and exceptions) is captured. If an entry point is sampled out, all related events are not captured. By default, Nightwatch has a sample rate of 100% for all entry points, resulting in unrestricted data collection and complete visibility out of the box.Recommended
We recommend everyone to apply some level of Sampling to reduce the volume of data collected. For new applications, we recommend starting with the global sample rate of0.1 or lower on requests to build an understanding of your application’s profile and adjusting the rate based on your observations.
Filtering
Filtering allows you to exclude specific events from collection with precision. Once a trace has been selected for collection through sampling, filters can be applied to individual events based on criteria, allowing you to make granular decisions about what should be collected or excluded. Please see the following guides for how to apply filtering to the following event types:Inline filtering
In addition to the callback-based filtering above, you may also filter events inline. TheNightwatch::ignore method accepts a callback which will filter out any events occurring within the callback:
Nightwatch::pause and Nightwatch::resume methods instead.
Redaction
Redaction allows you to manipulate collected data before it’s sent to Nightwatch. After data has passed through sampling and filtering, redaction methods enable you to obfuscate sensitive information, modify user details, or add contextual information to records. Please see the following guides for how to apply redaction to the following event types:Rate limiting
In addition to sampling and filtering, you may also cap the number of events ingested by Nightwatch. This can be useful to ensure a noisy application does not consume all of your quota. Before ingesting, Nightwatch dispatches theLaravel\Nightwatch\Events\IngestingEvents event. When a listener returns false, the ingest will be canceled. Combining this event with Laravel’s rate limiter allows you to cap ingestion at the application or environment level, or even across several applications that share a cache.
The following example listener, which is typically registered in a service provider’s boot method, limits the application to 1,000 events per day:
Events occurring while the listener executes, such as the cache operations performed by the rate limiter, will not be collected by Nightwatch.