Skip to content

Instantly share code, notes, and snippets.

@muxx
Last active November 1, 2019 12:28
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save muxx/9cc8b65a9105c8ba18a8 to your computer and use it in GitHub Desktop.
Save muxx/9cc8b65a9105c8ba18a8 to your computer and use it in GitHub Desktop.
pinba configure in Bitrix
<?php
include __DIR__ . '/pinba_configure.php';
<?php
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']);
}
if (function_exists('pinba_timer_add')) {
global $DB;
$DB->ShowSqlStat = true;
AddEventHandler("main", "OnAfterEpilog", "PinbaTimersRegister");
}
function PinbaTimersRegister() {
global $DB;
$pinbaData = pinba_get_info();
$initTags = array();
if (isset($pinbaData['hostname'])) {
$initTags['__hostname'] = $pinbaData['hostname'];
}
if (isset($pinbaData['server_name'])) {
$initTags['__server_name'] = $pinbaData['server_name'];
}
foreach ($DB->arQueryDebug as $item) {
$tags = $initTags;
$tags['server'] = $DB->DBHost;
$tags['category'] = 'database';
//select, insert, update, ...
if (preg_match('/^\s*(\w+)\s/', $item['QUERY'], $matches)) {
$tags['group'] = 'database::' . strtolower($matches[1]);
}
pinba_timer_add($tags, $item['TIME']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment