Download the PHP package tzabzlat/yii2-sentry without Composer
On this page you can find all versions of the php package tzabzlat/yii2-sentry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tzabzlat/yii2-sentry
More information about tzabzlat/yii2-sentry
Files in tzabzlat/yii2-sentry
Package yii2-sentry
Short Description Sentry integration for Yii2 framework with performance monitoring and error tracking
License MIT
Informations about the package yii2-sentry
Yii2 Sentry
Read this in other languages: Русский
Complete Sentry integration for Yii2 framework: logging, tracing and profiling.
Features
- Tracking errors and exceptions through Yii2 logs
- Database performance monitoring (slow queries, transactions)
- HTTP request tracing (incoming and outgoing)
- Manual spans for tracking performance of critical operations
- Flexible data collection configuration through collector system
- Sanitization of sensitive data (passwords, tokens, API keys)
Installation
Install the package via composer:
For using performance profiling features, you need to install the PHP Excimer extension.
Configuration
Basic Configuration
Add to your application configuration (not common
):
Built-in Collectors
The package includes four main collectors, each responsible for its own monitoring area:
1. LogCollector
Collects and sends Yii2 logs with error and warning levels to Sentry. Allows configuring which logs should be sent and which should be ignored.
2. DbCollector
Tracks SQL queries, measures their performance, and creates spans in Sentry for analysis. Automatically marks slow queries. Also tracks database transactions.
3. HttpClientCollector
Tracks outgoing HTTP requests made through Yii2 HttpClient. Measures response time, records response status, and creates spans for visualizing HTTP dependencies.
4. RequestCollector
Tracks incoming HTTP requests to your application. Creates the main transaction for each request and collects information about the controller, action, processing time, and response status.
Usage
Manual Spans for Custom Operations
To create spans manually, use the trace
method:
Collector Configuration
You can configure each collector separately through the collectorsConfig
parameter:
Disabling Collectors
To disable a specific collector, set its configuration to false
:
How Collectors Work
LogCollector
Connects a special LogTarget that intercepts logs with specified levels and sends them to Sentry. Processes exceptions as a separate type of event. Also supports filtering by categories and message patterns.
DbCollector
Overrides the standard Yii2 DbCommand and connects to query profiling events. Measures the execution time of each SQL query, determines the query type (SELECT, INSERT, etc.), and creates spans for visualization in Sentry. Tracks transactions through Connection events.
HttpClientCollector
Subscribes to request sending events through HttpClient. For each request, it creates a span with details of URL, method, headers, and request body (with sanitization of sensitive data). Measures response time and adds information about the response status.
RequestCollector
Creates the main transaction for each incoming HTTP request. Collects information about the route, controller, action, request parameters, and response. Measures the total request processing time and peak memory usage.
Creating a Custom Collector
You can create your own collector by implementing the CollectorInterface
or extending the BaseCollector
class:
Then add your collector to the configuration:
Contributing
If you found a bug or have suggestions for improvement, feel free to:
- Create an issue with a description of the problem or suggestion
- Propose pull requests with fixes or new features
License
MIT