Metrics Collection
Track call counts, durations, and errors per operation
Count calls, time durations, and track errors per operation — then query them in your tests.
metrics.Collector · counts, durations, errors
Setup#
import "github.com/stackshy/cloudemu/v2/features/metrics"
mc := &metrics.Collector{}
bucket := storage.NewBucket(aws.S3,
storage.WithMetrics(mc),
)Automatic metrics#
Every operation automatically records:
calls_total— counter incremented on each callcall_duration— histogram of call durationserrors_total— counter incremented on errors
All metrics include labels: service and operation.
Querying metrics#
// Get all counters
counters := mc.Query(metrics.Query{
Type: metrics.CounterType,
Name: "calls_total",
})
// Filter by labels
storagePuts := mc.Query(metrics.Query{
Type: metrics.CounterType,
Name: "calls_total",
Labels: map[string]string{"operation": "PutObject"},
})Metric types#
| Type | Description |
|---|---|
CounterType | Monotonically increasing counter |
GaugeType | Value that can go up and down |
HistogramType | Distribution of values (durations) |