ekino/metric-bundle

该包已被废弃,不再维护。没有建议的替代包。

将Ekino PHP Metric集成到Symfony2

dev-master 2013-03-25 09:53 UTC

This package is auto-updated.

Last update: 2024-02-25 21:41:00 UTC


README

Build Status

将Ekino PHP Metric集成到Symfony2

警告 - 此bundle与挂起的pull请求一起工作

要求

  • 此代码必须在 CollectDStatsD 运行的情况下运行
  • 用户必须对收集和聚合数据/解决方案有良好的理解

安装

使用Composer

使用 composer.phar

$ php composer.phar require ekino/metric-bundle

您只需指定您想要的版本: dev-master。它将在您的 composer.json 文件中添加包并安装它。

或者您可以自己操作,首先,将以下内容添加到您的 composer.json 文件中

// composer.json
{
    // ...
    require: {
        // ...
        "ekino/metric-bundle": "dev-master"
    }
}

然后,您可以通过在 composer.json 文件所在的目录中运行Composer的 update 命令来安装新的依赖项

$ php composer.phar update ekino/metric-bundle

配置

ekino_metric:
    metrics:
        - { type: timer, service: "event_dispatcher::dispatch",   name: "php.symfony.event_dispatcher.{arg0}" }
        - { type: timer, service: "http_kernel::handle",          name: "php.symfony.http_kernel.handle" }
        - { type: timer, service: "templating::render",           name: "php.symfony.twig.render.{arg0}" }
        - { type: timer, service: "mailer::send",                 name: "php.mailer.send" }
        - { type: timer, service: "router::match",                name: "php.symfony.router.match"}
        - { type: timer, service: "router::generate",             name: "php.symfony.router.generate.{arg0}"}

    reporter: ekino.metric.reporter.statsd # ekino.metric.reporter.collectd

    reporters:
        collectd:
            hostname:   web1-php    # the hostname to send to collectd
            udp_host:   localhost   # the host where the UDP stream need to be send
            udp_port:   25826       # the port where the UDP stream need to be send

        statsd:
            udp_host:   localhost
            udp_port:   8125

        newrelic:
            application_name: Awesome Aplication # (mandatory, default value in newrelic is PHP Application)
            api_key:                             # New Relic API

Doctrine Collector

如果您想收集关于Doctrine查询的信息,您需要启用Doctrine分析器。

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                profiling: true
                driver:    %database_driver%
                dbname:    %database_name%
                user:      %database_user%
                host:      %database_host%
                password:  %database_password%

ekino_metric:
    [...]
    collectors: # configure built in collectors
        doctrine:
            prefix: 'mysql.query'

    collect_from:   # configure services to retrieve metric from
        - ekino.metric.collector.doctrine