Add Response Time column to health check table
This commit is contained in:
parent
7e59b7e88b
commit
1957e273ec
|
@ -99,7 +99,7 @@ class EnvironmentCheckSuite
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run this test suite and return the result code of the worst result.
|
* Run this test suite and return the result code of the worst result and the time it took.
|
||||||
*
|
*
|
||||||
* @return EnvironmentCheckSuiteResult
|
* @return EnvironmentCheckSuiteResult
|
||||||
*/
|
*/
|
||||||
|
@ -110,13 +110,15 @@ class EnvironmentCheckSuite
|
||||||
foreach ($this->checkInstances() as $check) {
|
foreach ($this->checkInstances() as $check) {
|
||||||
list($checkClass, $checkTitle) = $check;
|
list($checkClass, $checkTitle) = $check;
|
||||||
try {
|
try {
|
||||||
|
$startTime = microtime(true);
|
||||||
list($status, $message) = $checkClass->check();
|
list($status, $message) = $checkClass->check();
|
||||||
|
$responseTime = number_format((microtime(true) - $startTime), 4, '.', '') . 's';
|
||||||
// If the check fails, register that as an error
|
// If the check fails, register that as an error
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$status = EnvironmentCheck::ERROR;
|
$status = EnvironmentCheck::ERROR;
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
}
|
}
|
||||||
$result->addResult($status, $message, $checkTitle);
|
$result->addResult($status, $message, $checkTitle, $responseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -35,12 +35,13 @@ class EnvironmentCheckSuiteResult extends ViewableData
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $checkIdentifier
|
* @param string $checkIdentifier
|
||||||
*/
|
*/
|
||||||
public function addResult($status, $message, $checkIdentifier)
|
public function addResult($status, $message, $checkIdentifier, $responseTime)
|
||||||
{
|
{
|
||||||
$this->details->push(new ArrayData([
|
$this->details->push(new ArrayData([
|
||||||
'Check' => $checkIdentifier,
|
'Check' => $checkIdentifier,
|
||||||
'Status' => $this->statusText($status),
|
'Status' => $this->statusText($status),
|
||||||
'StatusCode' => $status,
|
'StatusCode' => $status,
|
||||||
|
'ResponseTime' => $responseTime,
|
||||||
'Message' => $message,
|
'Message' => $message,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@
|
||||||
|
|
||||||
<% if $IncludeDetails %>
|
<% if $IncludeDetails %>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Check</th> <th>Status</th> <th>Message</th></tr>
|
<tr><th>Check</th> <th>Status</th> <th>Response Time</th> <th>Message</th></tr>
|
||||||
<% loop $Details %>
|
<% loop $Details %>
|
||||||
<tr><td>$Check</td> <td class="$Status">$Status</td> <td>$Message.XML</td></tr>
|
<tr><td>$Check</td> <td class="$Status">$Status</td> <td class="$ResponseTime">$ResponseTime</td> <td>$Message.XML</td></tr>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</table>
|
</table>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
Loading…
Reference in New Issue