Add "request time" event and viewer and context data to Multimeter

Summary: Ref T6930. Only notable thing here is that I prevented non-admins from slicing down by viewing user, since it feels a little creepy to go see what pages you looked at, even though we only show which controllers you invoked. However, it feels important enough to be able to see users destorying the server with crazy requests to let admins see this data.

Test Plan: {F389718}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6930

Differential Revision: https://secure.phabricator.com/D12630
This commit is contained in:
epriestley
2015-05-01 13:20:30 -07:00
parent 1448073314
commit 59416a13e7
4 changed files with 77 additions and 11 deletions

View File

@@ -125,7 +125,11 @@ abstract class AphrontApplicationConfiguration {
$processing_exception = null;
try {
$response = $application->processRequest($request, $access_log, $sink);
$response = $application->processRequest(
$request,
$access_log,
$sink,
$multimeter);
$response_code = $response->getHTTPResponseCode();
} catch (Exception $ex) {
$processing_exception = $ex;
@@ -140,6 +144,11 @@ abstract class AphrontApplicationConfiguration {
'T' => PhabricatorStartup::getMicrosecondsSinceStart(),
));
$multimeter->newEvent(
MultimeterEvent::TYPE_REQUEST_TIME,
$multimeter->getEventContext(),
PhabricatorStartup::getMicrosecondsSinceStart());
$access_log->write();
$multimeter->saveEvents();
@@ -171,16 +180,19 @@ abstract class AphrontApplicationConfiguration {
public function processRequest(
AphrontRequest $request,
PhutilDeferredLog $access_log,
AphrontHTTPSink $sink) {
AphrontHTTPSink $sink,
MultimeterControl $multimeter) {
$this->setRequest($request);
list($controller, $uri_data) = $this->buildController();
$controller_class = get_class($controller);
$access_log->setData(
array(
'C' => get_class($controller),
'C' => $controller_class,
));
$multimeter->setEventContext('web.'.$controller_class);
$request->setURIMap($uri_data);
$controller->setRequest($request);
@@ -198,6 +210,7 @@ abstract class AphrontApplicationConfiguration {
'u' => $request->getUser()->getUserName(),
'P' => $request->getUser()->getPHID(),
));
$multimeter->setEventViewer('user.'.$request->getUser()->getPHID());
}
if (!$response) {