When a page is profiled, profile all AJAX requests too
Summary: If a page is profiled, add an "X-Phabricator-Profiler" header to all Ajax requests, and profile those too. Test Plan: Profiled a page, checked Darkconsole, saw profiles for everything. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4885
This commit is contained in:
@@ -1174,7 +1174,7 @@ celerity_register_resource_map(array(
|
||||
),
|
||||
'javelin-behavior-dark-console' =>
|
||||
array(
|
||||
'uri' => '/res/ae7f15ce/rsrc/js/application/core/behavior-dark-console.js',
|
||||
'uri' => '/res/89aeb6c0/rsrc/js/application/core/behavior-dark-console.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
@@ -3488,7 +3488,7 @@ celerity_register_resource_map(array(
|
||||
'uri' => '/res/pkg/bc0774e5/core.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'3e0098ea' =>
|
||||
'dca4a03d' =>
|
||||
array(
|
||||
'name' => 'darkconsole.pkg.js',
|
||||
'symbols' =>
|
||||
@@ -3496,7 +3496,7 @@ celerity_register_resource_map(array(
|
||||
0 => 'javelin-behavior-dark-console',
|
||||
1 => 'javelin-behavior-error-log',
|
||||
),
|
||||
'uri' => '/res/pkg/3e0098ea/darkconsole.pkg.js',
|
||||
'uri' => '/res/pkg/dca4a03d/darkconsole.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'8aaacd1b' =>
|
||||
@@ -3666,7 +3666,7 @@ celerity_register_resource_map(array(
|
||||
'javelin-behavior-aphront-drag-and-drop-textarea' => '95d0d865',
|
||||
'javelin-behavior-aphront-form-disable-on-submit' => 'bc0774e5',
|
||||
'javelin-behavior-audit-preview' => 'f96657b8',
|
||||
'javelin-behavior-dark-console' => '3e0098ea',
|
||||
'javelin-behavior-dark-console' => 'dca4a03d',
|
||||
'javelin-behavior-device' => 'bc0774e5',
|
||||
'javelin-behavior-differential-accept-with-errors' => '95d0d865',
|
||||
'javelin-behavior-differential-add-reviewers-and-ccs' => '95d0d865',
|
||||
@@ -3682,7 +3682,7 @@ celerity_register_resource_map(array(
|
||||
'javelin-behavior-differential-user-select' => '95d0d865',
|
||||
'javelin-behavior-diffusion-commit-graph' => 'f96657b8',
|
||||
'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8',
|
||||
'javelin-behavior-error-log' => '3e0098ea',
|
||||
'javelin-behavior-error-log' => 'dca4a03d',
|
||||
'javelin-behavior-global-drag-and-drop' => 'bc0774e5',
|
||||
'javelin-behavior-konami' => 'bc0774e5',
|
||||
'javelin-behavior-lightbox-attachments' => 'bc0774e5',
|
||||
|
||||
@@ -13,11 +13,23 @@ final class DarkConsoleXHProfPluginAPI {
|
||||
return extension_loaded('xhprof');
|
||||
}
|
||||
|
||||
public static function getProfilerHeader() {
|
||||
return 'X-Phabricator-Profiler';
|
||||
}
|
||||
|
||||
public static function isProfilerRequested() {
|
||||
if (!empty($_REQUEST['__profile__'])) {
|
||||
return $_REQUEST['__profile__'];
|
||||
}
|
||||
|
||||
$header = self::getProfilerHeader();
|
||||
$header = strtoupper($header);
|
||||
$header = str_replace('-', '_', $header);
|
||||
$header = 'HTTP_'.$header;
|
||||
if (!empty($_SERVER[$header])) {
|
||||
return $_SERVER[$header];
|
||||
}
|
||||
|
||||
static $profilerRequested = null;
|
||||
|
||||
if (!isset($profilerRequested)) {
|
||||
|
||||
@@ -147,6 +147,7 @@ final class CelerityStaticResourceResponse {
|
||||
$higher_priority_names = array(
|
||||
'refresh-csrf',
|
||||
'aphront-basic-tokenizer',
|
||||
'dark-console',
|
||||
);
|
||||
|
||||
$higher_priority_behaviors = array_select_keys(
|
||||
|
||||
@@ -161,12 +161,19 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
||||
|
||||
if ($console) {
|
||||
require_celerity_resource('aphront-dark-console-css');
|
||||
|
||||
$headers = array();
|
||||
if (DarkConsoleXHProfPluginAPI::isProfilerRequested()) {
|
||||
$headers[DarkConsoleXHProfPluginAPI::getProfilerHeader()] = 'page';
|
||||
}
|
||||
|
||||
Javelin::initBehavior(
|
||||
'dark-console',
|
||||
array(
|
||||
'uri' => $request ? (string)$request->getRequestURI() : '?',
|
||||
'selected' => $user ? $user->getConsoleTab() : null,
|
||||
'visible' => $user ? (int)$user->getConsoleVisible() : true,
|
||||
'headers' => $headers,
|
||||
));
|
||||
|
||||
// Change this to initBehavior when there is some behavior to initialize
|
||||
|
||||
Reference in New Issue
Block a user