Path: blob/master/src/applications/multimeter/storage/MultimeterEvent.php
12256 views
<?php12final class MultimeterEvent extends MultimeterDAO {34const TYPE_STATIC_RESOURCE = 0;5const TYPE_REQUEST_TIME = 1;6const TYPE_EXEC_TIME = 2;78protected $eventType;9protected $eventLabelID;10protected $resourceCost;11protected $sampleRate;12protected $eventContextID;13protected $eventHostID;14protected $eventViewerID;15protected $epoch;16protected $requestKey;1718private $eventLabel;1920public function setEventLabel($event_label) {21$this->eventLabel = $event_label;22return $this;23}2425public function getEventLabel() {26return $this->eventLabel;27}2829public static function getEventTypeName($type) {30switch ($type) {31case self::TYPE_STATIC_RESOURCE:32return pht('Static Resource');33case self::TYPE_REQUEST_TIME:34return pht('Web Request');35case self::TYPE_EXEC_TIME:36return pht('Subprocesses');37}3839return pht('Unknown ("%s")', $type);40}4142public static function formatResourceCost(43PhabricatorUser $viewer,44$type,45$cost) {4647switch ($type) {48case self::TYPE_STATIC_RESOURCE:49return pht('%s Req', new PhutilNumber($cost));50case self::TYPE_REQUEST_TIME:51case self::TYPE_EXEC_TIME:52return pht('%s us', new PhutilNumber($cost));53}5455return pht('%s Unit(s)', new PhutilNumber($cost));56}575859protected function getConfiguration() {60return array(61self::CONFIG_TIMESTAMPS => false,62self::CONFIG_COLUMN_SCHEMA => array(63'eventType' => 'uint32',64'resourceCost' => 'sint64',65'sampleRate' => 'uint32',66'requestKey' => 'bytes12',67),68self::CONFIG_KEY_SCHEMA => array(69'key_request' => array(70'columns' => array('requestKey'),71),72'key_type' => array(73'columns' => array('eventType', 'epoch'),74),75),76) + parent::getConfiguration();77}7879}808182