Skip to content

Commit 1e77bd5

Browse files
authored
Merge pull request #28 from encero/apcu-present-check
Throw StorageException in APC when apc-ext is missing or disabled
2 parents e16ce9a + d055837 commit 1e77bd5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Prometheus/Storage/APC.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,29 @@
55
namespace Prometheus\Storage;
66

77
use APCUIterator;
8+
use Prometheus\Exception\StorageException;
89
use Prometheus\MetricFamilySamples;
910
use RuntimeException;
1011

1112
class APC implements Adapter
1213
{
1314
const PROMETHEUS_PREFIX = 'prom';
1415

16+
/**
17+
* APC constructor.
18+
*
19+
* @throws StorageException
20+
*/
21+
public function __construct()
22+
{
23+
if (!extension_loaded('apcu')) {
24+
throw new StorageException('APCu extension is not loaded');
25+
}
26+
if (!apcu_enabled()) {
27+
throw new StorageException('APCu is not enabled');
28+
}
29+
}
30+
1531
/**
1632
* @return MetricFamilySamples[]
1733
*/

0 commit comments

Comments
 (0)