Symfony
Bundle for Symfony 6.4+
The official DockRay package integrates Symfony applications with the monitoring platform and automatically reports exceptions, console command errors, and HTTP request processing times. Events are sent directly to the DockRay dashboard along with the information needed to quickly diagnose issues.
Error and Exception Monitoring
DockRay integrates with Symfony’s exception handling system and reports errors that occur while processing HTTP requests.
Reported events can include:
- the exception type and message,
- where the exception occurred and the stack trace,
- environment and application version information,
- context related to the request being processed.
Selected exception classes can be excluded from reporting, such as 404 errors generated by NotFoundHttpException.
Performance Monitoring
The package can monitor the processing time of main HTTP requests and send transactions to DockRay. The frequency of data collection can be controlled using a sampling rate.
Selected paths, such as the Symfony profiler, can be excluded from performance monitoring.
Console Commands
DockRay can also report errors from Symfony Console commands. Events are tagged with the command name, making it easier to diagnose issues that occur outside standard HTTP requests.
User Context and Privacy
If the application uses the Symfony Security component, DockRay can optionally include information about the authenticated user with reported events. Sending the IP address and user agent is controlled by a separate setting.
Developer Features
The DockRay Hub is available as a Symfony service and can be injected into your own classes. This allows you to manually report caught exceptions from anywhere in your application.
The integration also supports long-running processes and workers, using a single DockRay client instance throughout the lifetime of the process.
Installation
Package Installation
Install DockRay using Composer:
composer require dockcodes/dock-ray-symfony
If your project uses Symfony Flex, the bundle will be registered automatically.
If your project does not use Symfony Flex, register the bundle manually in config/bundles.php:
<?php
return [
// ...
Dock\Ray\Symfony\RayBundle::class => ['all' => true],
];
Configuration
Create or update the config/packages/ray.yaml file:
ray:
token: '%env(RAY_TOKEN)%'
private_key: '%env(RAY_PRIVATE_KEY)%'
traces_sample_rate: 0.2
ignore_exceptions:
- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Then add your DockRay project credentials to the .env file:
RAY_TOKEN=project-token
RAY_PRIVATE_KEY=project-private-key
You can find your project token and private key in the DockRay dashboard. Without these values, the bundle will load but will not send any data.
Additional settings allow you to configure the environment, application version, error and transaction sampling, user data, and exceptions and paths that should be excluded from monitoring.