You can easily set up end-to-end observability for a Laravel application running on Forge using Middleware.
Steps to Follow:
- Install the Middleware agent according as per your configuration.
- Run the Laravel instrumentation script.
curl -O https://install.middleware.io/apm/php/laravel-instrument.php
COMPOSER_ALLOW_SUPERUSER=1 php laravel-instrument.php install
- Logs and traces are enabled by default.
- To enable metrics, please follow the documentation provided here.
- Finally, before running the application, make sure to implement the following changes.
Set this in your environment variable and restart your app to start the instrumentation.
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=your-service-name
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:9320
To correlate frontend traces with backend traces, add the following environment variable:
OTEL_PROPAGATORS=baggage,tracecontext,b3multi
Hurrah your observability setup is done.