Skip to content
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
34 changes: 15 additions & 19 deletions src/Usage/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ abstract public function getTimeSeries(array $metrics, string $interval, string
* @param string $metric Metric name
* @param array<\Utopia\Query\Query> $queries Additional query filters
* @param string|null $type Metric type: 'event', 'gauge', or null (query both)
* @return int
*/
abstract public function getTotal(string $metric, array $queries = [], ?string $type = null): int;

Expand All @@ -80,16 +79,16 @@ abstract public function getTotalBatch(array $metrics, array $queries = [], ?str
* Purge usage metrics matching the given queries.
* When no queries are provided, all metrics are deleted.
*
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (purge both)
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (purge both)
*/
abstract public function purge(array $queries = [], ?string $type = null): bool;

/**
* Find metrics using Query objects.
*
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (query both)
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (query both)
* @return array<Metric>
*/
abstract public function find(array $queries = [], ?string $type = null): array;
Expand All @@ -102,10 +101,9 @@ abstract public function find(array $queries = [], ?string $type = null): array;
* This keeps large counts cheap for endpoints that only need a capped
* total. When $max is null the count is unbounded.
*
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (count both)
* @param int|null $max Optional upper bound for the count (inclusive)
* @return int
* @param array<\Utopia\Query\Query> $queries
* @param string|null $type Metric type: 'event', 'gauge', or null (count both)
* @param int|null $max Optional upper bound for the count (inclusive)
*/
abstract public function count(array $queries = [], ?string $type = null, ?int $max = null): int;

Expand All @@ -115,10 +113,9 @@ abstract public function count(array $queries = [], ?string $type = null, ?int $
* Events-only by default because summing gauges is semantically meaningless
* (adding point-in-time snapshots doesn't produce a useful total).
*
* @param array<\Utopia\Query\Query> $queries
* @param string $attribute Attribute to sum (default: 'value')
* @param string $type Metric type: 'event' or 'gauge'
* @return int
* @param array<\Utopia\Query\Query> $queries
* @param string $attribute Attribute to sum (default: 'value')
* @param string $type Metric type: 'event' or 'gauge'
*/
abstract public function sum(array $queries = [], string $attribute = 'value', string $type = Usage::TYPE_EVENT): int;

Expand All @@ -130,7 +127,7 @@ abstract public function sum(array $queries = [], string $attribute = 'value', s
* Note: Daily MV only stores event metrics. This method always queries
* the daily events table — gauges are never pre-aggregated.
*
* @param array<\Utopia\Query\Query> $queries Filters (metric, time range, resource, etc.)
* @param array<\Utopia\Query\Query> $queries Filters (metric, time range, resource, etc.)
* @return array<Metric>
*/
abstract public function findDaily(array $queries = []): array;
Expand All @@ -141,9 +138,8 @@ abstract public function findDaily(array $queries = []): array;
* Note: Daily MV only stores event metrics. This method always queries
* the daily events table — gauges are never pre-aggregated.
*
* @param array<\Utopia\Query\Query> $queries
* @param string $attribute Attribute to sum (default: 'value')
* @return int
* @param array<\Utopia\Query\Query> $queries
* @param string $attribute Attribute to sum (default: 'value')
*/
abstract public function sumDaily(array $queries = [], string $attribute = 'value'): int;

Expand All @@ -153,8 +149,8 @@ abstract public function sumDaily(array $queries = [], string $attribute = 'valu
* Note: Daily MV only stores event metrics. This method always queries
* the daily events table — gauges are never pre-aggregated.
*
* @param array<string> $metrics List of metric names
* @param array<\Utopia\Query\Query> $queries Additional filters (e.g. date range)
* @param array<string> $metrics List of metric names
* @param array<\Utopia\Query\Query> $queries Additional filters (e.g. date range)
* @return array<string, int> Metric name => sum value
*/
abstract public function sumDailyBatch(array $metrics, array $queries = []): array;
Expand Down
Loading
Loading