9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PhalconでNew Relicのトランザクション解析機能を使う

Last updated at Posted at 2014-08-05

パフォーマンス監視サービスの New Relic 使ってますか? 便利ですよね。

しかしながら、残念なことにPHPのMVCフレームワークのPhalconには標準対応しておりません。そこで、dispatcherの設定をいじって対応する方法をまとめておきます。

設定方法

public/index.php(MultiModuleの場合はMudule.php)のdispatcherを設定している箇所を以下のように書き換えます。

public/index.php
// Registering a dispatcher
$di->set('dispatcher', function () {
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
    $dispatcher->setDefaultNamespace('Your\NameSpace');
    if (extension_loaded('newrelic')) {
        $manager = new \Phalcon\Events\Manager();
        $manager->attach('dispatch', function ($event, $dispatcher) {
            $controller = $dispatcher->getControllerName();
            $action     = $dispatcher->getActionName();
            newrelic_name_transaction($controller . '/' . $action);
        });
        $dispatcher->setEventsManager($manager);
    }
    return $dispatcher;
});

参考URL

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?