Skip to main content

Module counting

Module counting 

Source
Expand description

Defines CountingBackend, a decorator for the Backend trait that emits Cost of Goods Sold (COGS) compute usage metrics to the cogs.usage counter.

CountingBackend is meant to wrap the outer-most Backend implementation owned by StorageService so that every tracked backend operation, whether a single-object operation called by StorageService or a batched operation streamed by StreamExecutor, is counted once. Notably, any operation that fails before it gets to StorageService (e.g. an auth or rate limit failure at a higher layer) is not counted.

For COGS purposes we use operation count as a proxy for compute cost under the assumption that each request we serve has a basically flat CPU cost. Large payloads take longer, but they can be streamed in the background while other requests are served so they don’t really cost more.

Structs§

CountingBackend
A Backend decorator that counts each operation performed for COGS. Also implements MultipartUploadBackend. See the module documentation for how it should be used.