Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.
Open
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
8 changes: 8 additions & 0 deletions src/Prometheus/CollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public static function getDefault()
return self::$defaultRegistry;
}

/**
* @return boolean
*/
public function initialized()
{
return $this->storageAdapter->initialized();
}

/**
* @return MetricFamilySamples[]
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Prometheus/Storage/APC.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ class APC implements Adapter
{
const PROMETHEUS_PREFIX = 'prom';

/**
* @return boolean
*/
public function initialized()
{
return !apc_add(self::PROMETHEUS_PREFIX . ":initialized", true);
}

/**
* @return MetricFamilySamples[]
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Prometheus/Storage/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ interface Adapter
const COMMAND_INCREMENT_FLOAT = 2;
const COMMAND_SET = 3;

/**
* @return boolean
*/
public function initialized();

/**
* @return MetricFamilySamples[]
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Prometheus/Storage/InMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ class InMemory implements Adapter
private $counters = [];
private $gauges = [];
private $histograms = [];
private $initialized = false;

/**
* @return boolean
*/
public function initialized()
{
if(!$this->initialized){
$this->initialized = true;
return false;
}
return $this->initialized;
}

/**
* @return MetricFamilySamples[]
Expand All @@ -28,6 +41,7 @@ public function flushMemory()
$this->counters = [];
$this->gauges = [];
$this->histograms = [];
$this->initialized = false;
}

private function collectHistograms()
Expand Down
5 changes: 5 additions & 0 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class Redis implements Adapter
private $options;
private $redis;

public function initialized()
{
return $this->redis->getSet(self::$prefix . 'INITIALIZED', 1);
}

public function __construct(array $options = array())
{
// with php 5.3 we cannot initialize the options directly on the field definition
Expand Down