Turn off instrumentation
Turn off one instrumentation
Section titled “Turn off one instrumentation”Each built-in instrumentation has its own switch. To stop recording cache operations, for example:
METRICS_CACHE=false| Variable | Stops |
|---|---|
METRICS_HTTP |
http.server.request.duration |
METRICS_DB |
db.client.operation.duration, laravel.db.transaction.duration and laravel.db.queries |
METRICS_ELOQUENT |
laravel.eloquent.models and laravel.eloquent.models.pruned |
METRICS_QUEUE |
messaging.process.duration and messaging.client.sent.messages |
METRICS_CACHE |
laravel.cache.operations |
METRICS_SCHEDULER |
laravel.scheduler.task.duration |
METRICS_EXCEPTIONS |
laravel.exceptions |
METRICS_RUNTIME |
The metrics read on export: laravel.info, OPcache, PHP-FPM, load average, disk usage |
METRICS_DB_SERVER |
laravel.db.server.connections and laravel.db.server.connections.max, read on export |
METRICS_MIGRATIONS |
laravel.db.migrations.pending, read on export |
If the configuration is cached, run php artisan config:cache again. Then restart the queue workers with php artisan queue:restart, or php artisan horizon:terminate with Horizon.
The series recorded before the switch stay in the store and are still exported. To hide them, see Leave metrics out of exports.
Turn off metrics as a whole
Section titled “Turn off metrics as a whole”METRICS_ENABLED=falseWith metrics off:
- nothing is recorded, and nothing touches the store;
- no listener and no scrape route are registered;
- every export is empty, even if the store still holds older values.
metrics:push still runs, and prints The store holds no metrics.
Turn off metrics in tests
Section titled “Turn off metrics in tests”To keep tests away from the store, set the variable in phpunit.xml:
<php> <env name="METRICS_ENABLED" value="false"/></php>Metrics::fake() needs metrics on. To assert metrics in some tests, keep metrics on and use an in-memory cache instead. See Test your metrics.