Pageserver: billing events sent to Vector and S3 should use the same idempotency key #8605
Labels
c/storage/pageserver
Component: storage: pageserver
t/bug
Issue Type: Bug
triaged
bugs that were already triaged
Problem
The idempotency key is used to make sure that events are not recorded more than once, although they may be submitted multiple times in some cases to make sure they are not lost.
We should calculate the idempotency key beforehand and send the same events to S3 and Vector.
Relates (internal issue): https://github.com/neondatabase/cloud/issues/9824
Detail
Consumption metrics for billing are written over a socket to an external service (Vector), and also written to S3 for posterity.
In
consumption_metrics.rs
, we call two output methods with the same vector of metric values:upload::upload_metrics_bucket
upload::upload_metrics_http
Each of these ultimately uses RawMetric::as_event on each metric to add an "idempotency key" to the entry: this enables the billing system to receive delta metrics (e.g. data written since last sample) without risking double-counting on retries.
To ensure the S3 output and the Vector output have the same idempotency key, we need to pull the calculation of the keys up into
collect_metrics
, and pass those with the RawMetrics into each upload function, so that the uploads aren't independently calculating different keys.The text was updated successfully, but these errors were encountered: