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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ composer require utopia-php/usage
use Utopia\Usage\Usage;
use Utopia\Usage\Adapter\ClickHouse;

// Configuration is fixed at construction; only the tenant changes per request.
$adapter = new ClickHouse(
host: 'clickhouse-server',
username: 'default',
password: '',
port: 8123,
secure: false
secure: false,
namespace: 'my_app',
sharedTables: true,
);

// Multi-tenant setup
$adapter->setNamespace('my_app');
$adapter->setSharedTables(true);
$adapter->setTenant('project_123');

$usage = new Usage($adapter);
Expand Down Expand Up @@ -333,9 +332,11 @@ Extend `Utopia\Usage\Adapter` and implement:
- `sumDaily(array $queries, string $attribute): int`
- `sumDailyBatch(array $metrics, array $queries): array`
- `purge(array $queries, ?string $type): bool`
- `setNamespace(string $namespace): self`
- `setTenant(?string $tenant): self`
- `setSharedTables(bool $sharedTables): self`

Namespace, database, shared-tables mode, async inserts, query logging and the
dual-read sample rate are set once via the adapter constructor (see "Using
ClickHouse Adapter" above). Only the tenant changes over an instance's lifetime.

## System Requirements

Expand Down
14 changes: 0 additions & 14 deletions src/Usage/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,4 @@ abstract public function sumDaily(array $queries = [], string $attribute = 'valu
* @return array<string, int> Metric name => sum value
*/
abstract public function sumDailyBatch(array $metrics, array $queries = []): array;

/**
* Enable parity sampling for routed reads. At rate=0 the sampler is
* disabled (default). At rate>0 each routed read is re-executed against
* the raw table with the given probability and logs a dual_read_warning
* entry when totals diverge by more than 1%. Pass 1.0 for every-read
* sampling (CI use) or small values (0.01) for production canaries.
*
* Adapters without parity sampling override this with a no-op.
*/
public function setDualReadSampleRate(float $rate): self
{
return $this;
}
}
Loading
Loading