forked from PromPHP/prometheus_client_php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsome_histogram.php
More file actions
27 lines (20 loc) · 816 Bytes
/
some_histogram.php
File metadata and controls
27 lines (20 loc) · 816 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
27
<?php
require __DIR__ . '/../vendor/autoload.php';
use Prometheus\CollectorRegistry;
use Prometheus\Storage\Redis;
error_log('c=' . $_GET['c']);
$adapter = $_GET['adapter'];
if ($adapter === 'redis') {
Redis::setDefaultOptions(['host' => $_SERVER['REDIS_HOST'] ?? '127.0.0.1']);
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'apcng') {
$adapter = new Prometheus\Storage\APCng();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemory();
}
$registry = new CollectorRegistry($adapter);
$histogram = $registry->registerHistogram('test', 'some_histogram', 'it observes', ['type'], [0.1, 1, 2, 3.5, 4, 5, 6, 7, 8, 9]);
$histogram->observe($_GET['c'], ['blue']);
echo "OK\n";