Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

PHP 5.3 support #3

Merged
merged 5 commits into from
Jun 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: php
php:
- 5.6
- 5.3

services:
- redis-server
Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
}
],
"require": {
"php": ">=5.6.0",
"php": ">=5.3.3",
"ext-redis": "*"
},
"require-dev": {
"phpunit/phpunit": "5.4.6",
"guzzlehttp/guzzle": "~6.0"
"phpunit/phpunit": "4.1.0"
},
"suggest": {
"guzzlehttp/guzzle": "~6.0 for running the blackbox tests."
},
"autoload": {
"psr-0": {
Expand Down
14 changes: 7 additions & 7 deletions src/Prometheus/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ class RedisAdapter
const PROMETHEUS_SAMPLE_LABEL_VALUES_SUFFIX = '_LABEL_VALUES';
const PROMETHEUS_SAMPLE_NAME_SUFFIX = '_NAME';

const METRIC_TYPES = [
Gauge::TYPE,
Counter::TYPE,
Histogram::TYPE,
];

private $hostname;
private $redis;
private $metricTypes;

public function __construct($hostname)
{
$this->hostname = $hostname;
$this->redis = new \Redis();
$this->metricTypes = array(
Gauge::TYPE,
Counter::TYPE,
Histogram::TYPE,
);
}

public function flushRedis()
Expand All @@ -54,7 +54,7 @@ public function fetchMetrics()
{
$this->openConnection();
$metrics = array();
foreach (self::METRIC_TYPES as $metricType) {
foreach ($this->metricTypes as $metricType) {
$metrics = array_merge($metrics, $this->fetchMetricsByType($metricType));
}
return $metrics;
Expand Down
3 changes: 2 additions & 1 deletion src/Prometheus/RenderTextFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function render(array $metrics)
private function renderSample(Sample $sample)
{
$escapedLabels = array();
if (!empty($sample->getLabels())) {
$labels = $sample->getLabels();
if (!empty($labels)) {
foreach ($sample->getLabels() as $labelName => $labelValue) {
$escapedLabels[] = $labelName . '="' . $this->escapeLabelValue($labelValue) . '"';
}
Expand Down