forked from Wikia/app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.php
More file actions
26 lines (18 loc) · 755 Bytes
/
metrics.php
File metadata and controls
26 lines (18 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
* This is an HTTP end-point that exposes metrics for Prometheus
*
* @see SUS-5855
*/
// Prometheus does not set a "Host" header,
// tell WikiFactoryLoader class which wiki to use when serving this request
$_ENV['SERVER_ID'] = 2393201;
require __DIR__ . '/includes/WebStart.php'; // we want to load config to have $wgRedisHost
use Prometheus\CollectorRegistry;
use Prometheus\RenderTextFormat;
$adapter = new Prometheus\Storage\Redis( [ 'host' => $wgRedisHost ] );
$registry = new CollectorRegistry($adapter);
$renderer = new RenderTextFormat();
header( 'Content-Type: ' . RenderTextFormat::MIME_TYPE );
header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
echo $renderer->render( $registry->getMetricFamilySamples() );