networkteam/sentry-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

networkteam/sentry-client

Composer 安装命令:

composer require networkteam/sentry-client

包简介

A Sentry client for TYPO3. It forwards errors and exceptions to Sentry - https://sentry.io/

README 文档

README

ci Latest release on GitHub Downloads per month

TYPO3 logs error messages and exceptions to logfiles and the backend log module. This extension sends them to Sentry, a SaaS/self-hosted application which aggregates them and informs you by mail. In Sentry you see a error messages with additional information like stacktrace, HTTP headers and submitted request/form data.

Technical decisions

Exceptions through database outages (imagine a mysql server restart) should not be reported, so the db connection is checked before. Exceptions may be excluded via regexp on their message (won't fix this error => exclude it). TYPO3 throws a lot of PHP Notices and they are not really interesting in production, they are excluded by default.

Installation

$ composer require networkteam/sentry-client

The TER version will not receive updates anymore. Feel free to send us a crate of beer and we will make a new TER release.

Configuration

File: system/settings.php or system/additional.php

Register the exception handlers.

$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = Networkteam\SentryClient\ProductionExceptionHandler::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = Networkteam\SentryClient\DebugExceptionHandler::class;

The DebugExceptionHandler is also used in production environment when SYS/displayErrors is enabled and your IP matches SYS/devIPmask.

Optional: Forward non-exceptional errors to Sentry, that normally are logged only. Consider using LogLevel::WARN

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
        \Networkteam\SentryClient\SentryLogWriter::class => [],
    ],
];

Optional: Set sentry/sentry options (https://docs.sentry.io/platforms/php/configuration/options/)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sentry_client']['options']['server_name'] = 'web3';

Environment variables

Since Sentry SDK 2.x there are environment variables which can be used, for example in a .htaccess file:

SetEnv SENTRY_DSN http://public_key@your-sentry-server.com/project-id
SetEnv SENTRY_RELEASE 1.0.7
SetEnv SENTRY_ENVIRONMENT Staging

Feature Toggles

  • Ignore database connection errors (they should better be handled by a monitoring system)
  • Report user information: Select one of none | userid
  • Ignore exception message regular expression
  • Ignore LogWriter Components

How to test if the extension works?

page = PAGE
page.20 = USER
page.20 {
  userFunc = Networkteam\SentryClient\Client->captureException
}

This triggers an error that will be reported.

Request ID

If the web server has set a request ID header X-Request-Id, this is transmitted as a tag to trace errors to logs.

Issue tracker

This extension is managed on GitHub. Feel free to get in touch at https://github.com/networkteam/sentry_client

Help

There is a Slack channel #ext-sentry_client

Changelog

6.0.0

  • Add TYPO3 v14 support
  • !!! Drop TYPO3 v11 support (EOL)

5.2.1

  • Do not capture exceptions that TYPO3 Content Object Exception Handler is configured to re-throw via config.contentObjectExceptionHandler.ignoreCodes

5.2.0

  • Add TYPO3 v13 support

5.1.1

  • Use TYPO3 HTTP configuration (verify, http_timeout, connect_timeout) for Sentry HTTP client
  • Support both [HTTP][proxy] and [HTTP][proxy][http] proxy configuration formats

5.1.0

  • Use sentry/sentry ^4.6

5.0.0

  • New option "disableDatabaseLogging": When enabled, exceptions are not written to database table sys_log
  • Introduce Sentry Integrations
  • Allow passing sentry/sentry options via EXTCONF
  • Ignore exceptions, that are ignore in TYPO3 core
  • Use sentry/sentry instead of sentry/sdk (Thanks to @derhansen)
  • !!! Option "logWriterLogLevel" removed. LogWriter needs to be configured in system/additional.php
  • !!! Option "messageBlacklistRegex" renamed to "ignoreMessageRegex"
  • !!! Option "logWriterComponentBlacklist" renamed to "logWriterComponentIgnorelist"
  • !!! The old option names still work
  • !!! Drop support for TYPO3 v10
  • !!! Drop support for non-composer usage

4.2.0

  • Add log message interpolation (Thanks to @sascha-egerer)
  • Add Fingerprint to log messages
  • Deprecated: Usage of DebugExceptionHandler

4.1.0

  • Client IP is anonymized with IpAnonymizationUtility::anonymizeIp(). Thanks to @extcode
  • Add X-Request-Id as tag. Thanks to @bergo
  • Small code optimizations. Thanks to @tlueder and @LeoniePhiline

4.0.0

  • Add stacktrace to LogWriter messages for message grouping in Sentry
  • Add LogWriter component ignorelist
  • Add v11.5 support
  • Drop v9.5 support

3.0..3.1

  • Add experimental LogWriter
  • Remove setting activatePageNotFoundHandling
  • Ignore PageNotFoundException by default
  • Support TYPO3 proxy setting
  • Use sentry/sdk:3.1

2.0..3.0

  • Use sentry/sdk:2.0
  • Remove setting productionOnly
  • Remove setting reportWithDevIP
  • Rename setting activatePageNotFoundHandlingActive to activatePageNotFoundHandling
  • Report E_ALL ^ E_NOTICE
  • Strip project root
  • Show event id in FE

networkteam/sentry-client 适用场景与选型建议

networkteam/sentry-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09M 次下载、GitHub Stars 达 39, 最近一次更新时间为 2018 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「extension」 「monitoring」 「sentry」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 networkteam/sentry-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 networkteam/sentry-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 networkteam/sentry-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.09M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 39
  • 点击次数: 25
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 39
  • Watchers: 7
  • Forks: 40
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2018-02-08