Skip to content
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ build/
test.php
coverage/
!coverage/.gitkeep
prometheus.db
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/Storage/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<<SQL
Expand Down Expand Up @@ -782,7 +786,11 @@ public function wipeStorage(): void
$this->database->truncateTables(...$tables);
}

/** @throws DatabaseException */
/**
* Drop all tables.
*
* @throws DatabaseException
*/
public function deleteStorage(): void
{
$tables = [
Expand Down