TABLE
TABLE = 'strata_provider_stat'
The table this store lives in.
Keeps what each store was asked to do, accumulated per day.
A ProviderStats is an accumulator for one request; this is the record. Without it every reading the budget guard, the cost report and the telemetry pass can take describes only the process that is asking, so a site that flushes in a queue worker and reports in a web request can never see its own bill.
One row per provider, day and operation. A day is a whole number of days since the epoch at midnight UTC, which keeps a row addressable without a date function and makes the primary key do the accumulating: a second flush on the same day adds to the row the first one wrote.
Durations are stored in whole milliseconds. A float column would carry more precision than an HTTP round trip has, and an integer sums exactly however many times it is added to.
Nothing here is authoritative and nothing else reads it back to work: it is an observation of traffic that already happened, which is why an uninstall dropping the table costs nothing but the history of the bill.
__construct(\Drupal\Core\Database\Connection $database, \Drupal\Component\Datetime\TimeInterface $time) : mixed
Constructs a store.
| \Drupal\Core\Database\Connection | $database | The database. |
| \Drupal\Component\Datetime\TimeInterface | $time | The clock, so a test can place a reading on a chosen day. |
record(string $provider, \Drupal\strata\Storage\ProviderStats $stats, int|null $at = null) : int
Folds one window into the rows for its day.
Idempotent in shape rather than in effect: calling it twice with the same window counts that window twice, which is correct, because a window is a set of requests that were made. A caller that persists an accumulator is expected to reset it, and ProviderStats::reset() exists for exactly that.
| string | $provider | The provider id the window belongs to. |
| \Drupal\strata\Storage\ProviderStats | $stats | The window. Left unchanged. |
| int|null | $at | Unix timestamp the window belongs to. NULL uses the request time. |
How many operation rows were written or updated. Zero when the window recorded nothing.
total(int $from = 0, int $to = 0) : array{requests: int, failures: int, bytes: int, seconds: float, classA: int, classB: int}
Everything recorded over a window, as one set of figures.
| int | $from | Unix timestamp to read from. Zero reads from the first row. |
| int | $to | Unix timestamp to read to. Zero reads to the last row. |
All zeroes when nothing was recorded in the window.
byOperation(int $from = 0, int $to = 0) : array<string,array{requests: int, failures: int, bytes: int, seconds: float, slowest: float}>
Per-operation figures over a window, summed across every provider.
Operations with no rows are left out, so a table rendered from this shows the verbs the store was actually asked for. Order follows ProviderStats::OPERATIONS.
| int | $from | Unix timestamp to read from. Zero reads from the first row. |
| int | $to | Unix timestamp to read to. Zero reads to the last row. |
Keyed by operation.
byProvider(int $from = 0, int $to = 0) : array<string,array{requests: int, failures: int, bytes: int, seconds: float, slowest: float}>
Per-provider figures over a window, summed across every operation.
| int | $from | Unix timestamp to read from. Zero reads from the first row. |
| int | $to | Unix timestamp to read to. Zero reads to the last row. |
Keyed by provider id, busiest first.
daily(int $from = 0, int $to = 0) : list<array{day: int, requests: int, failures: int, bytes: int, seconds: float, slowest: float}>
Daily totals over a window, oldest first.
A day with no traffic has no row, so a graph drawn from this joins the points it has rather than reading a gap as a zero.
| int | $from | Unix timestamp to read from. Zero reads from the first row. |
| int | $to | Unix timestamp to read to. Zero reads to the last row. |
One entry per day that has traffic.
aggregate(string $column, int $from, int $to) : array<string,array{requests: int, failures: int, bytes: int, seconds: float, slowest: float}>
Sums the figure columns grouped by one column.
| string | $column | One of |
| int | $from | Unix timestamp to read from. Zero reads from the first row. |
| int | $to | Unix timestamp to read to. Zero reads to the last row. |
Keyed by the grouping column's value.