-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a /metrics endpoint, to export stats about the size of the database table. (This is currently PDO-only.) Bug: T256039 Change-Id: I5f83c6fe648db6065a46ef51a110fe4278bfaeaf Signed-off-by: Elan Ruusamäe <[email protected]>
- Loading branch information
Showing
7 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Slim\Slim; | ||
|
||
class Xhgui_Controller_Metrics extends Xhgui_Controller | ||
{ | ||
/** | ||
* @var Xhgui_Searcher_Interface | ||
*/ | ||
protected $searcher; | ||
|
||
public function __construct(Slim $app, Xhgui_Searcher_Interface $searcher) | ||
{ | ||
parent::__construct($app); | ||
$this->searcher = $searcher; | ||
} | ||
|
||
public function metrics() | ||
{ | ||
$request = $this->app->request(); | ||
$response = $this->app->response(); | ||
|
||
$stats = $this->searcher->stats(); | ||
|
||
$body = "# HELP xhgui_profiles_total Number of profiles collected.\n"; | ||
$body .= "# TYPE xhgui_profiles_total gauge\n"; | ||
$body .= sprintf("xhgui_profiles_total %0.1F\n\n", $stats['profiles']); | ||
|
||
$body .= "# HELP xhgui_profile_bytes_total Size of profiles collected.\n"; | ||
$body .= "# TYPE xhgui_profile_bytes_total gauge\n"; | ||
$body .= sprintf("xhgui_profile_bytes_total %0.1F\n\n", $stats['bytes']); | ||
|
||
$body .= "# HELP xhgui_latest_profile_seconds UNIX timestamp of most recent profile.\n"; | ||
$body .= "# TYPE xhgui_latest_profile_seconds gauge\n"; | ||
$body .= sprintf("xhgui_latest_profile_seconds %0.1F\n", $stats['latest']); | ||
|
||
$response->body($body); | ||
$response['Content-Type'] = 'text/plain; version=0.0.4'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters