Last active
November 1, 2019 12:28
-
-
Save muxx/9cc8b65a9105c8ba18a8 to your computer and use it in GitHub Desktop.
pinba configure in Bitrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . '/pinba_configure.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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