2011-02-02 22:48:52 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 19:18:11 +01:00
|
|
|
final class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
|
2011-02-02 22:48:52 +01:00
|
|
|
|
2013-04-02 15:26:26 +02:00
|
|
|
protected $profileFilePHID;
|
2011-02-02 22:48:52 +01:00
|
|
|
|
|
|
|
public function getName() {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return 'XHProf';
|
|
|
|
}
|
2011-02-02 22:48:52 +01:00
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function getColor() {
|
|
|
|
$data = $this->getData();
|
2013-04-02 15:26:26 +02:00
|
|
|
if ($data['profileFilePHID']) {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return '#ff00ff';
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return null;
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return 'Provides detailed PHP profiling information through XHProf.';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generateData() {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return array(
|
2013-04-02 15:26:26 +02:00
|
|
|
'profileFilePHID' => $this->profileFilePHID,
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
'profileURI' => (string)$this
|
|
|
|
->getRequestURI()
|
|
|
|
->alter('__profile__', 'page'),
|
|
|
|
);
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getXHProfRunID() {
|
2013-04-02 15:26:26 +02:00
|
|
|
return $this->profileFilePHID;
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function renderPanel() {
|
|
|
|
$data = $this->getData();
|
|
|
|
|
2013-04-02 15:26:26 +02:00
|
|
|
$run = $data['profileFilePHID'];
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
$profile_uri = $data['profileURI'];
|
|
|
|
|
2011-02-02 22:48:52 +01:00
|
|
|
if (!DarkConsoleXHProfPluginAPI::isProfilerAvailable()) {
|
2014-03-17 23:01:31 +01:00
|
|
|
$href = PhabricatorEnv::getDoclink('Installation Guide');
|
2013-01-18 03:57:09 +01:00
|
|
|
$install_guide = phutil_tag(
|
2011-07-09 18:45:19 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
'class' => 'bright-link',
|
|
|
|
),
|
|
|
|
'Installation Guide');
|
2013-02-13 23:50:15 +01:00
|
|
|
return hsprintf(
|
2011-07-09 18:45:19 +02:00
|
|
|
'<div class="dark-console-no-content">'.
|
|
|
|
'The "xhprof" PHP extension is not available. Install xhprof '.
|
|
|
|
'to enable the XHProf console plugin. You can find instructions in '.
|
2013-02-13 23:50:15 +01:00
|
|
|
'the %s.'.
|
|
|
|
'</div>',
|
|
|
|
$install_guide);
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
2011-02-06 21:58:01 +01:00
|
|
|
|
2011-07-09 18:45:19 +02:00
|
|
|
$result = array();
|
|
|
|
|
2013-11-09 05:44:24 +01:00
|
|
|
$header = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'dark-console-panel-header'),
|
|
|
|
array(
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $profile_uri,
|
|
|
|
'class' => $run ? 'disabled button' : 'green button',
|
|
|
|
),
|
|
|
|
pht('Profile Page')),
|
|
|
|
phutil_tag('h1', array(), pht('XHProf Profiler')),
|
|
|
|
));
|
2011-07-09 18:45:19 +02:00
|
|
|
$result[] = $header;
|
2011-02-06 21:58:01 +01:00
|
|
|
|
2011-07-09 18:45:19 +02:00
|
|
|
if ($run) {
|
2013-11-09 05:44:24 +01:00
|
|
|
$result[] = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => "/xhprof/profile/$run/",
|
|
|
|
'class' => 'bright-link',
|
|
|
|
'style' => 'float: right; margin: 1em 2em 0 0; font-weight: bold;',
|
|
|
|
'target' => '_blank',
|
|
|
|
),
|
|
|
|
pht('Profile Permalink'));
|
2013-11-14 02:08:24 +01:00
|
|
|
$result[] = phutil_tag(
|
2013-11-09 05:44:24 +01:00
|
|
|
'iframe',
|
|
|
|
array('src' => "/xhprof/profile/$run/?frame=true"));
|
2011-07-09 18:45:19 +02:00
|
|
|
} else {
|
2013-11-09 05:44:24 +01:00
|
|
|
$result[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'dark-console-no-content'),
|
|
|
|
pht(
|
2011-07-09 18:45:19 +02:00
|
|
|
'Profiling was not enabled for this page. Use the button above '.
|
2013-11-09 05:44:24 +01:00
|
|
|
'to enable it.'));
|
2011-02-03 01:14:23 +01:00
|
|
|
}
|
2011-07-09 18:45:19 +02:00
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
return phutil_implode_html("\n", $result);
|
2011-02-03 01:14:23 +01:00
|
|
|
}
|
|
|
|
|
2011-02-02 22:48:52 +01:00
|
|
|
|
2011-02-03 01:14:23 +01:00
|
|
|
public function willShutdown() {
|
2013-04-02 15:26:26 +02:00
|
|
|
$this->profileFilePHID = DarkConsoleXHProfPluginAPI::getProfileFilePHID();
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|