michaelslobodskih/yii2-sentry-fresh
Composer 安装命令:
composer require michaelslobodskih/yii2-sentry-fresh
包简介
Yii2 integration for Sentry
README 文档
README
Yii2 integration for Sentry using Sentry PHP SDK v3.
Inspired by official sentry/sentry-symfony and sentry/sentry-laravel packages.
Installation
The preferred way to install this package is through composer:
composer require exileed/yii2-sentry
Package doesn't provide any HTTP transport out of the box. To install package with a recommended HTTP client use special metapackage:
composer require php-http/curl-client
Basic Usage
Add "sentry" component to application's config and to bootstrapping, then configure log target as follows:
<?php return [ 'id' => 'my-app', 'bootstrap' => [ 'sentry', 'log', ], 'components' => [ 'sentry' => [ 'class' => OlegTsvetkov\Yii2\Sentry\Component::class, 'dsn' => 'https://abcdefghijklmnopqrstuvwxyz123456@sentry.io/0000000', ], 'log' => [ 'targets' => [ [ 'class' => OlegTsvetkov\Yii2\Sentry\LogTarget::class, 'levels' => ['error', 'warning'], 'except' => [ 'yii\web\HttpException:40*', ], ], ], ], ], ];
Don't forget to change DSN to your own.
After this all exceptions (except blacklisted), PHP errors and calls for Yii::error() and Yii:warning() will be
logged to Sentry.
It is highly recommended to blacklist all Yii's exceptions for 40x responses, because they are used for handling requests and doesn't indicate about problems of any kind.
Out of the box component provides detailed information about request, such as:
- Request Method
- Request URL (including query string)
- Request Headers
- Request Body
- Resolved route (goes to tags)
- User ID for logged in
- Visitor's IP address
- Visitor's Cookies (with send default PII enabled)
- App environment (taken from
YII_ENV) - Stack trace for exception
Important nuance about LogTarget
Bundled in Log Target will send only one message to Sentry per request. This message will be based on the log entry with highest severity level. All other entries will go to the extra field "logs" of message
Advanced usage
Sentry client configuration
Component provides out-of-box configuration for Sentry client. It can be overridden and extend using
Component::$sentrySettings property. Use options from Sentry PHP SDK as-is.
Also, Sentry's ClientBuilder is being created using Yii's container, which allows custom builder injection.
Personally identifying information (PII) handling
By default Sentry provides PII handling on it's side, but it doesn't give full control over PII stripping process. Because of this, Yii2 Sentry package is able to strip PPI from both request headers and request body.
Example of component configuration with a complete list of PII-related settings:
<?php [ 'class' => OlegTsvetkov\Yii2\Sentry\Component::class, 'dsn' => 'https://abcdefghijklmnopqrstuvwxyz123456:abcdefghijklmnopqrstuvwxyz123456@sentry.io/0000000', 'integrations' => [ [ 'class' => OlegTsvetkov\Yii2\Sentry\Integration::class, // Headers that should not be send to Sentry at all 'stripHeaders' => ['cookie', 'set-cookie'], // Headers which values should be filtered before sending to Sentry 'piiHeaders' => ['custom-token-header', 'authorization'], // Body fields which values should be filtered before sending to Sentry 'piiBodyFields' => [ 'controller/action' => [ 'field_1' => [ 'field_2', ], 'field_2', ], 'account/login' => [ 'email', 'password', ], ], // Text to replace PII values with 'piiReplaceText' => '[Filtered PII]', ], Sentry\Integration\ErrorListenerIntegration::class, ], ]
michaelslobodskih/yii2-sentry-fresh 适用场景与选型建议
michaelslobodskih/yii2-sentry-fresh 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 994 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「errors」 「sdk」 「sentry」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 michaelslobodskih/yii2-sentry-fresh 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 michaelslobodskih/yii2-sentry-fresh 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 michaelslobodskih/yii2-sentry-fresh 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
Bootstraps errors and handles them via reporters and renderers
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
Monitors errors and exceptions and reports them to Rollbar
统计信息
- 总下载量: 994
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-08-05