
accounting
Index
- type OperationRecordFunc
- type Recorder
- func New(usage *counter.UsageTracker, recordOp OperationRecordFunc) *Recorder
- func (r *Recorder) APICall(backend string)
- func (r *Recorder) APICalls(backend string, n int64)
- func (r *Recorder) Egress(backend string, sizeBytes int64)
- func (r *Recorder) GetSuccess(operation, backend string, sizeBytes int64, start time.Time)
- func (r *Recorder) Ingress(backend string, sizeBytes int64)
- func (r *Recorder) Operation(operation, backend string, start time.Time, err error)
- func (r *Recorder) OperationFailed(operation, backend string, start time.Time, err error)
- func (r *Recorder) PutSuccess(operation, backend string, sizeBytes int64, start time.Time)
type OperationRecordFunc
OperationRecordFunc is the per-operation metric callback. Wraps the existing Prometheus operation histogram so the Recorder does not have to import the metrics package directly.
type Recorder
Recorder centralizes the per-backend accounting rules. Safe for concurrent use: all state lives on the underlying UsageTracker and OperationRecordFunc, which are themselves safe.
func New
New constructs a Recorder. usage credits the per-backend API call and ingress/egress byte counters; recordOp emits the per-operation Prometheus histogram observation.
func (*Recorder) APICall
APICall credits one API call against the backend’s usage counter. Call after every attempt that contacted the backend, regardless of outcome: the HTTP call was made either way.
func (*Recorder) APICalls
APICalls credits n API calls against the backend’s usage counter. For paginated lists, multipart completes that touch many part objects, and other multi-call operations.
func (*Recorder) Egress
Egress credits one API call + sizeBytes of egress on the backend. Use after a successful GET-like operation (the bytes left the backend toward the client).
func (*Recorder) GetSuccess
GetSuccess is the canonical “GET succeeded” pair: emit the per-op metric with a nil error and credit one API call + egress bytes.
func (*Recorder) Ingress
Ingress credits one API call + sizeBytes of ingress on the backend. Use after a successful PUT-like operation (the bytes arrived at the backend from the client).
func (*Recorder) Operation
Operation emits the per-operation Prometheus histogram observation. Pair with APICall / Egress / Ingress for the usage-counter side; the two surfaces are deliberately separate so callers can record the API-call charge on failure paths without also emitting a fake success observation.
func (*Recorder) OperationFailed
OperationFailed is the canonical “the call reached the backend and failed” pair: emit the per-op metric with the err and credit one API call (no bytes, since nothing transferred).
func (*Recorder) PutSuccess
PutSuccess is the canonical “PUT succeeded” pair: emit the per-op metric with a nil error and credit one API call + ingress bytes.
Generated by gomarkdoc