承接 classmarkets/raven-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

classmarkets/raven-bundle

最新稳定版本:3.0.0

Composer 安装命令:

composer require classmarkets/raven-bundle

包简介

Display sentry event ids on error pages

README 文档

README

Build Status Scrutinizer Code Quality

Are you using sentry for exception monitoring in Symfony 2? Good! Now let's show meaningful error pages to your users.

Sentry generates ids for each event it receives. This bundle adds a Twig function that let's you access those event ids in error page templates:

<h1>Oh no, something went wrong!</h1>

{% if exception is defined %}
    {% set eventId = sentry_event_id(exception) %}

    {% if eventId is not empty %}
        <p>
            The good news is that our team has been notified and is probably
            working on a solution already.
        </p>
        
        <p>
            Error Code: <code>{{ eventId }}</code>
        </p>
    {% endif %}
{% endif %}

You can also lookup event ids wherever the DIC is available like this:

<?php

$container->get('cm_raven.sentry_event_recorder')->getEventIdForException($exception);

Installation

The usual. Install it with composer require classmarkets/raven-bundle ~1.0.0 and add it to the kernel:

<?php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Classmarkets\RavenBundle\CMRavenBundle(),
        );
    }

Configuration

Quickstart

Assuming you are using Monolog's raven handler already, and have not changed the twig.exception_listener service, you already have something like this:

monolog:
    raven:
        type:  raven
        dsn: %sentry_dsn%
        level: error

Turn it into this:

monolog:
    raven:
        type:  raven
        dsn: "" # some versions of the monolog bundle require the dsn key to
                # be present (even if it is empty)
        client_id: raven
        level: error

cm_raven:
    client_id: raven

services:
    raven:
        class: Raven_Client
        arguments: [ %sentry_dsn% ]

If you already have monolog.raven.client_id configured, omit the extra service definition.

The important thing is that monolog.raven.client_id equals cm_raven.client_id.

If you are not using monolog, find the id for the service that provides the Raven_Client instance, and set cm_raven.client_id to that id.

How it works

There are two parts to this bundle. Remembering event ids and making them available to error pages.

The first part is easy. All we have to do is decorate a Raven_Client service with an event id recorder.

The second part is tricky because the original exception doesn't make it into the template engine. Instead, it gets converted into a FlattenException. This FlattenException is unknown to our event recorder (because it only saw the original exception).

The FlattenException gets created by some protected method in the twig.exception_listener service. To solve our problem, we replace that service to associate the FlattenException with the same event id as the original exception.

If your application already has a custom twig.exception_listener service, disable our implementation and call @cm_raven.sentry_event_recorder::addExceptionAlias($originalException, $flattenException) yourself (see ExceptionListener.php).

To disable the exception listener configure

cm_raven:
    enable_exception_listener: false

classmarkets/raven-bundle 适用场景与选型建议

classmarkets/raven-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.2k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 classmarkets/raven-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 15.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-06