Skip to content

Configure sending of readable script names in Pinba

Ilyas Salikhov edited this page May 5, 2014 · 7 revisions

By default Pinba extension sends value $_SERVER["SCRIPT_NAME"] in script_name. Sometimes it is not informative, for example when web application has one entry point.

Here there are tips for configure of sending URL or route name instead of script name in script_name field.

Symfony2

If you want just correct script_name then add this code before kernel initialization in web/app*.php:

...
require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

//configure Pinba
if (function_exists('pinba_script_name_set')) {
    pinba_script_name_set($_SERVER['REQUEST_URI']);
}

$kernel = new AppKernel('prod', false);
...

There is PinbaBundle which corrects script_name and collects metrics for Doctrine, Twig and Memcache.

Bitrix

Add in bitrix/php_interface/init.php code:

if (function_exists('pinba_script_name_set')) {
  if (strpos($APPLICATION->GetCurPage(), 'urlrewrite.php') === false)
      pinba_script_name_set($APPLICATION->GetCurPage(false));
  else
      pinba_script_name_set($_SERVER['REQUEST_URI']);
}

Advanced configuration example with timers initialization https://gist.github.com/muxx/9cc8b65a9105c8ba18a8

symfony 1

Add filter in apps/#your_app#/config/filters.yml:

pinba_init:
  class: pinbaInitFilter

Create filter file pinbaInitFilter.class.php in apps/#your_app#/lib/filter/ with code:

class pinbaInitFilter extends sfFilter
{
  public function execute($filterChain)
  {
    if (function_exists('pinba_script_name_set')) {
       $request=$this->getContext()->getRequest();
       $uri=$request->getUri();
       pinba_script_name_set($uri);
    }

    // Execute next filter
    $filterChain->execute();
  }
}

Clear cache:

$ php symfony clear:cache --app=#your_app#
Clone this wiki locally