Customization
Laritor is built to be highly configurable, so you can adapt it to your exact requirements.
Environment Variables
Section titled “Environment Variables”| Feature | Environment Variable | Default | Description |
|---|---|---|---|
| Backend API Key | LARITOR_BACKEND_KEY | — | Ingest API key used by Laritor’s backend to authenticate event submissions. |
| Ingest Endpoint URL | LARITOR_INGEST_ENDPOINT | — | Full URL where events are sent for ingestion. |
| Enable / Disable Laritor | LARITOR_ENABLED | false | Temporarily pause all event collection without uninstalling. |
| Environment Name | LARITOR_ENV | APP_ENV value | Override the detected environment name. |
| Server Name | LARITOR_SERVER_NAME | Hostname | Set a custom server name (useful for serverless environments). |
| Max Events Per Occurrence | LARITOR_MAX_EVENTS_PER_OCCURRENCE | 5000 | Limit events per request/command to control usage. |
| Ingest Events without an Occurrence | LARITOR_INGEST_EVENTS_WITHOUT_OCCURRENCE | true | Send events that are not associated with an occurrence. |
Filtering
Section titled “Filtering”While Laritor records every supported event by default, some applications may prefer to filter out unwanted events to reduce observability costs.
You can do this by defining a custom filter class to selectively exclude events such as specific routes, jobs, or queries.
This gives you full control over what gets tracked, helping you reduce noise and manage observability costs more effectively.
Step 1: Generate the Filter Override Class
Section titled “Step 1: Generate the Filter Override Class”Run the below command to generate a filter class which records all events by default. Useful if you want to record all events initially and override in the future based on your needs.
php artisan make:laritor-filterRun the below command to generate a filter class which records events only when an exception is occurred in your application. Useful if you want to use Laritor as an error tracker only instead of an observability platform but still want to have full visibility into all events when an exception is occurred.
php artisan make:laritor-filter exceptions-onlyRun the below command to generate a filter class which records events only when there is an issue detected. some of the default issues include failed requests(4xx, 5xx status codes), exceptions, slow requests, slow queries, failed jobs, failed commands, etc. Useful if you want to have full visibility into issues happening in your application but don’t want to pay the full observability price.
php artisan make:laritor-filter issues-onlyYou can override any method in this class to return true/false to determine whether a specific event should be recorded or not.
true- event is recordedfalse- event is not recorded
Step 2: Register the Override in AppServiceProvider
Section titled “Step 2: Register the Override in AppServiceProvider”In your app/Providers/AppServiceProvider.php file, register the filter class in the register() method as below:
public function register(): void{ $this->app->bind( \BinaryBuilds\LaritorClient\Override\LaritorOverride::class, \App\Laritor\LaritorDataFilter::class );}✅ Done! Laritor will now call your custom filter class as it prepares events for delivery.
Available Filter Overrides
Section titled “Available Filter Overrides”| Method | Description |
|---|---|
recordRequest($request, $response, $status, $duration, $user) | Return false to ignore an inbound request. |
recordQuery($query, $duration, $path) | Return false to ignore a query. |
recordException($exception) | Return false to ignore an exception. |
recordQueuedJob(string $connection, string $queue, string $job, string $status, $duration) | Return false to ignore a queued job. |
recordMail($mailable, $to, $subject) | Return false to ignore mail. |
recordNotification($notifiable, $notification) | Return false to ignore a notification. |
recordCommandOrScheduledTask(string $command, string $status, $duration) | Return false to ignore a command or scheduled task. |
recordOutboundRequest($url, $statusCode, $duration) | Return false to ignore an outbound request. |
recordCacheHit($cacheKey) | Return false to ignore a cache event. |
recordFeatureFlag($flag, $scope) | Return false to ignore a feature-flag check. |
recordLog($level, $message, array $context = []) | Return false to ignore a log entry. |
recordTaskScheduler() | Return false to ignore task-scheduler health tracking. |
isBot($request) | Return whether a request should be identified as a bot. |
Payload and Context Overrides
Section titled “Payload and Context Overrides”These methods control whether Laritor includes individual payload fields. Return false to omit the field. Request methods receive $request, $response, $status, $duration, $user; outbound-request methods receive $url, $statusCode, $duration.
| Method | Controls |
|---|---|
recordCommandContext(...), recordScheduledTaskContext(...), recordRequestContext(...), recordQueuedJobContext(...), recordLogContext(...) | Laravel context attached to the corresponding event |
recordDatabaseSchema() | Database schema collection |
recordQueryBindings($query, $duration, $path) | SQL query bindings |
recordRequestQueryParameters(...) | Inbound request query parameters |
recordRequestHeaders(...), recordRequestBody(...) | Inbound request headers and body |
recordResponseHeaders(...), recordResponseBody(...) | Inbound response headers and body |
recordSessionData(...) | Session data for inbound requests |
recordOutboundRequestHeaders(...), recordOutboundRequestBody(...) | Outbound request headers and body |
recordOutboundRequestResponseHeaders(...), recordOutboundRequestResponseBody(...) | Outbound response headers and body |
whitelistedVendors(): array | Vendors whose stack frames should be retained |
DefaultOverride records request and response headers and session data by default. Request and response bodies are disabled by default. Redaction is still applied to all recorded data.
Filtering Examples
Section titled “Filtering Examples”Ignore specific requests
Section titled “Ignore specific requests”public function recordRequest($request, $response, $status, $duration, $user): bool{ $path = $request->path();
if ( $path === 'health' || str_starts_with($path, 'telescope') || str_starts_with($path, 'horizon') || preg_match('/\.(js|css|jpg|jpeg|png|svg|gif|ico)$/i', $path) ) { return false; }
return true;}Ignore specific queries
Section titled “Ignore specific queries”public function recordQuery($query, $duration, $path): bool{ // Skip queries faster than 5ms if ($duration < 5) { return false; }
// Ignore Telescope and Horizon-related queries if (preg_match('/\b(telescope_entries|horizon_jobs|horizon_tags)\b/i', $query)) { return false; }
return true;}Ignore Specific Jobs
Section titled “Ignore Specific Jobs”public function recordQueuedJob(string $connection, string $queue, string $job, string $status, $duration): bool{ if ($queue === 'broadcasts') { return false; }
return true;}Mark Internal Bots As Not Bot
Section titled “Mark Internal Bots As Not Bot”By default, Laritor will identify bot requests based on the user agent string and mark them as bot requests. If your
internal applications such as a different app or microservices are making requests, They may be treated as bots.
To avoid this, you can override the isBot method to not tag your internal requests as bots.
public function isBot($request): bool{ $ua = strtolower($request->userAgent());
if (str_contains($ua, 'internal-bot')) { return false; }
return parent::isBot($request);}Redacting
Section titled “Redacting”Laritor automatically redacts sensitive data before it leaves your servers. You can further customize the redaction logic by overriding the default redactor. This allows you to mask, replace, or remove data like email addresses, user information, IPs, and more tailored to your app’s privacy requirements.
Step 1: Publish the Redactor Override Class
Section titled “Step 1: Publish the Redactor Override Class”Run the following artisan command to publish the redactor override class.
php artisan make:laritor-redactorThis command will create a new file in app/Laritor/LaritorDataRedactor.php. You can override any of the methods in
this class to redact the data as per your needs.
Step 2: Register Your Redactor
Section titled “Step 2: Register Your Redactor”In your app/Providers/AppServiceProvider.php, register the redactor in the boot() method as below:
public function boot(): void{ $this->app->bind( \BinaryBuilds\LaritorClient\Redactor\DataRedactor::class, \App\Laritor\LaritorDataRedactor::class );}✅ Once registered, Laritor will use your custom redactor for all outgoing data.
Available Redactors
Section titled “Available Redactors”| Redactor Method | What it redacts | Use case |
|---|---|---|
redactEmailAddress($email) | Email addresses | Replace or mask user emails |
redactString($text) | Generic string values | Redact log lines, message bodies, etc. |
redactArrayValue($key,$value) | Array key-value pairs | Redact keys like password, token, etc. |
redactAuthenticatedUser(): array | Authenticated user details | Return only anonymized or partial data |
redactIPAddress($ip) | IP addresses | Mask or remove client/server IPs |
redactUserAgent($ua) | User-Agent header | Strip or normalize browser/device info |
Redaction Examples
Section titled “Redaction Examples”Redact Email Address
Section titled “Redact Email Address”public function redactEmailAddress($address): string{ [$user, $domain] = explode('@', $address); return str_repeat('*', strlen($user)) . '@' . $domain;}Redact Sensitive Strings
Section titled “Redact Sensitive Strings”public function redactString($text): string{ // Redact common tokens or credentials in text $patterns = [ '/Bearer\s+[A-Za-z0-9\-_\.=]+/i' => '[REDACTED_TOKEN]', '/password\s*=\s*["\']?.+?["\']?/i' => 'password=[REDACTED]', ];
return preg_replace(array_keys($patterns), array_values($patterns), $text);}Redact Arrays
Section titled “Redact Arrays”Redact specific array keys from request payloads, query params, headers, etc.
public function redactArrayValue($key, $value): string{ $sensitiveKeys = [ 'password', 'token', 'access_token', 'refresh_token', 'api_key', 'secret', 'authorization', 'auth_token', ];
if (in_array(strtolower($key), $sensitiveKeys, true)) { return '*****'; }
return $value;}Customize / Redact Authenticated User
Section titled “Customize / Redact Authenticated User”Customize / Redact the logged-in user’s personal data:
public function redactAuthenticatedUser(): array{ $user = Auth::user();
return [ 'id' => $user?->id, 'name' => $user?->id ? 'User #' . $user->id : null, 'email' => $user?->id ? 'user' . $user->id . '@redacted.com' : null, ];}Bonus: Redact based on environment
Section titled “Bonus: Redact based on environment”public function redactString($text): string{ if (app()->environment('production')) { return '*REDACTED*'; }
return $text;}Send Additional Attributes For Authenticated User
Section titled “Send Additional Attributes For Authenticated User”To include details such as a user’s role or team, see the Additional Authenticated User Attributes guide →.
With these configuration options, you can fine-tune Laritor’s behavior to align with your application’s requirements, performance goals, and privacy policies.
If you need help with advanced customization or have a specific use case not covered in this guide, feel free to reach out. We’re happy to help!
Contact Us
Section titled “Contact Us”Email: [email protected]
Join: Laritor Discord