diff --git a/.gitignore b/.gitignore index 3c1454d..b193961 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ build/ test.php coverage/ !coverage/.gitkeep +prometheus.db \ No newline at end of file diff --git a/README.md b/README.md index 7adb3ad..f8c7f58 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,8 @@ Using SQLite with memory database is same as using InMemory Database. ```php use Rancoud\Database\Configurator; use Rancoud\Database\Database; +use Rancoud\Prometheus\Counter; +use Rancoud\Prometheus\Descriptor; use Rancoud\Prometheus\Storage\SQLite; $params = [ @@ -265,12 +267,12 @@ $configurator = new Configurator($params); $database = new Database($configurator); -$storage = new Rancoud\Prometheus\SQLite($database); +$storage = new SQLite($database); $counter = new Counter($storage, new Descriptor("example")); ``` -## Metric +## Collector (metric) Constructor ```php public function __construct(Adapter $storage, Descriptor $descriptor) @@ -460,7 +462,7 @@ Returns the default Registry (singleton). public static function getDefault(): self ``` -## Storage +## Storage (Adapter interface) Returns metrics (counter, gauge, histogram and summary) as iterable. If metric type and name is provided it will return only the specify metric. ```php @@ -524,6 +526,37 @@ Returns text of summaries metric as iterable. public function exposeSummaries(string $metricName = ''): iterable ``` +### SQLite +Returns text of counters metric as iterable. +```php +public function exposeCounters(string $metricName = ''): iterable +``` + +Returns text of gauges metric as iterable. +```php +public function exposeGauges(string $metricName = ''): iterable +``` + +Returns text of histograms metric as iterable. +```php +public function exposeHistograms(string $metricName = ''): iterable +``` + +Returns text of summaries metric as iterable. +```php +public function exposeSummaries(string $metricName = ''): iterable +``` + +Remove all expired summaries sample according to the TTL. +```php +public function deleteExpiredSummaries(): void +``` + +Drop all tables. +```php +public function deleteStorage(): void +``` + ## How to Dev `composer ci` for php-cs-fixer and phpunit and coverage `composer lint` for php-cs-fixer diff --git a/src/Storage/SQLite.php b/src/Storage/SQLite.php index 31e04e1..f68082e 100644 --- a/src/Storage/SQLite.php +++ b/src/Storage/SQLite.php @@ -742,7 +742,11 @@ protected function updateMetadata(Descriptor $descriptor, string $metricType): v ]); } - /** @throws DatabaseException */ + /** + * Remove all expired summaries sample according to the TTL. + * + * @throws DatabaseException + */ public function deleteExpiredSummaries(): void { $sql = <<database->truncateTables(...$tables); } - /** @throws DatabaseException */ + /** + * Drop all tables. + * + * @throws DatabaseException + */ public function deleteStorage(): void { $tables = [