Skip to content
Permalink
Browse files

Fix a few mixed types

  • Loading branch information...
LeSuisse committed Jun 7, 2019
1 parent 7a0775b commit f29a4c24a2bb313964ee22ae0de515e7a342a625
@@ -4,13 +4,13 @@
require __DIR__ . '/../vendor/autoload.php';
$adapter = $_GET['adapter'] ?? '';
$adapter = (string) $_GET['adapter'] ?? '';
$storage = null;
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$storage = new Prometheus\Storage\RedisStore($redis_client);
}
@@ -7,16 +7,18 @@
use Prometheus\Registry\CollectorRegistry;
use Prometheus\Renderer\RenderTextFormat;
$adapter = $_GET['adapter'] ?? '';
$adapter = (string) $_GET['adapter'] ?? '';
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$adapter = new Prometheus\Storage\RedisStore($redis_client);
} elseif ($adapter === 'apcu') {
$adapter = new Prometheus\Storage\APCUStore();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemoryStore();
} else {
$adapter = new Prometheus\Storage\NullStore();
}
$registry = new CollectorRegistry($adapter);
$renderer = new RenderTextFormat();
@@ -12,16 +12,18 @@
use Prometheus\Value\MetricLabelNames;
use Prometheus\Value\MetricName;
$adapter = $_GET['adapter'] ?? '';
$adapter = (string) $_GET['adapter'] ?? '';
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$adapter = new RedisStore($redis_client);
} elseif ($adapter === 'apcu') {
$adapter = new Prometheus\Storage\APCUStore();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemoryStore();
} else {
$adapter = new Prometheus\Storage\NullStore();
}
$registry = new CollectorRegistry($adapter);
@@ -8,16 +8,18 @@
use Prometheus\Value\MetricLabelNames;
use Prometheus\Value\MetricName;
$adapter = $_GET['adapter'];
$adapter = (string) $_GET['adapter'];
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$adapter = new Prometheus\Storage\RedisStore($redis_client);
} elseif ($adapter === 'apcu') {
$adapter = new Prometheus\Storage\APCUStore();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemoryStore();
} else {
$adapter = new Prometheus\Storage\NullStore();
}
$registry = new CollectorRegistry($adapter);
@@ -26,6 +28,6 @@
'it increases',
MetricLabelNames::fromNames('type')
);
$counter->incBy((int) $_GET['c'], 'blue');
$counter->incBy((float) $_GET['c'], 'blue');
echo "OK\n";
@@ -8,18 +8,18 @@
use Prometheus\Value\MetricLabelNames;
use Prometheus\Value\MetricName;
error_log('c=' . $_GET['c']);
$adapter = $_GET['adapter'] ?? '';
$adapter = (string) $_GET['adapter'] ?? '';
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$adapter = new Prometheus\Storage\RedisStore($redis_client);
} elseif ($adapter === 'apcu') {
$adapter = new Prometheus\Storage\APCUStore();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemoryStore();
} else {
$adapter = new Prometheus\Storage\NullStore();
}
$registry = new CollectorRegistry($adapter);
@@ -8,18 +8,18 @@
use Prometheus\Value\HistogramLabelNames;
use Prometheus\Value\MetricName;
error_log('c=' . $_GET['c']);
$adapter = $_GET['adapter'] ?? '';
$adapter = (string) $_GET['adapter'] ?? '';
if ($adapter === 'redis') {
$redis_client = new Redis();
$redis_client->connect($_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$redis_client->connect((string) $_SERVER['REDIS_HOST'] ?? '127.0.0.1');
$adapter = new Prometheus\Storage\RedisStore($redis_client);
} elseif ($adapter === 'apcu') {
$adapter = new Prometheus\Storage\APCUStore();
} elseif ($adapter === 'in-memory') {
$adapter = new Prometheus\Storage\InMemoryStore();
} else {
$adapter = new Prometheus\Storage\NullStore();
}
$registry = new CollectorRegistry($adapter);
@@ -69,7 +69,7 @@ public function updateHistogram(MetricName $name, float $value, array $buckets,
// Taken from https://github.com/prometheus/client_golang/blob/66058aac3a83021948e5fb12f1f408ff556b9037/prometheus/value.go#L91
$done = false;
while (! $done) {
$old = apcu_fetch($sumKey);
$old = (int) apcu_fetch($sumKey);
$done = apcu_cas($sumKey, $old, $this->toInteger($this->fromInteger($old) + $value));
}
@@ -104,7 +104,7 @@ public function addToGauge(MetricName $name, float $value, string $help, MetricL
// Taken from https://github.com/prometheus/client_golang/blob/66058aac3a83021948e5fb12f1f408ff556b9037/prometheus/value.go#L91
$done = false;
while (! $done) {
$old = apcu_fetch($valueKey);
$old = (int) apcu_fetch($valueKey);
$done = apcu_cas($valueKey, $old, $this->toInteger($this->fromInteger($old) + $value));
}
}
@@ -120,7 +120,7 @@ public function incrementCounter(MetricName $name, float $value, string $help, M
// Taken from https://github.com/prometheus/client_golang/blob/66058aac3a83021948e5fb12f1f408ff556b9037/prometheus/value.go#L91
$done = false;
while (! $done) {
$old = apcu_fetch($valueKey);
$old = (int) apcu_fetch($valueKey);
$done = apcu_cas($valueKey, $old, $this->toInteger($this->fromInteger($old) + $value));
}
}

0 comments on commit f29a4c2

Please sign in to comment.
You can’t perform that action at this time.