s3-orchestrator

metrics

import "github.com/afreidah/s3-orchestrator/internal/proxy/metrics"

Package metrics owns the Prometheus gauge/counter recording for the proxy package. It exposes a Collector that the orchestrator embeds to refresh gauge values from the metadata store and record per-operation metrics.

Index

type Collector

Collector records Prometheus metrics for manager-level operations and periodically refreshes gauge values from the metadata store.

type Collector struct {
    // contains filtered or unexported fields
}

func New

func New(store Deps, usage *counter.UsageTracker, backendNames []string, replicationFactor func() int) *Collector

New creates a Collector with references to the store and usage tracker needed for gauge refreshes.

func (*Collector) RecordOperation

func (mc *Collector) RecordOperation(operation, backend string, start time.Time, err error)

RecordOperation updates Prometheus request count and duration metrics for a single manager operation.

func (*Collector) UpdateQuotaMetrics

func (mc *Collector) UpdateQuotaMetrics(ctx context.Context) error

UpdateQuotaMetrics fetches quota stats, object counts, active multipart upload counts, and monthly usage, then updates the corresponding Prometheus gauges and caches usage baselines for limit enforcement.

type Deps

Deps is the narrow store surface Collector needs to refresh Prometheus gauges. Defined here - at the consumer - rather than in the store package: adding a new metric is a Collector concern, not a store-package concern.

type Deps interface {
    GetQuotaStats(ctx context.Context) (map[string]core.QuotaStat, error)
    GetObjectCounts(ctx context.Context) (map[string]int64, error)
    GetActiveMultipartCounts(ctx context.Context) (map[string]int64, error)
    GetUsageForPeriod(ctx context.Context, period string) (map[string]core.UsageStat, error)
    GetUnderReplicatedObjects(ctx context.Context, factor, limit int) ([]core.ObjectLocation, error)
}

Generated by gomarkdoc