Documentation
¶
Index ¶
Constants ¶
const NumBuckets = stats.NumBuckets
NumBuckets is re-exported from internal/stats so callers in the distributed layer can size bucket arrays without importing internal/stats directly.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator collects execution metrics for the MVP.
func NewAggregator ¶
func NewAggregator() *Aggregator
NewAggregator creates an empty metrics aggregator and allocates the native stats engine used for low-memory percentile estimates.
func (*Aggregator) Close ¶ added in v0.3.7
func (a *Aggregator) Close()
Close releases the C++ stats engine. Safe to call more than once. Do not use this aggregator for recording after Close.
func (*Aggregator) Record ¶
func (a *Aggregator) Record(latency time.Duration, statusCode int, err error)
Record stores metrics for a single execution.
func (*Aggregator) Result ¶
func (a *Aggregator) Result(duration time.Duration) Result
Result returns the aggregated metrics snapshot. Multiple calls with no intervening Close() return consistent percentile estimates (same engine state). Call Close() when the test run is finished to release the native engine.
type LatencyStats ¶
type LatencyStats struct {
Min time.Duration
Max time.Duration
Mean time.Duration
P50 time.Duration
P90 time.Duration
P95 time.Duration
P99 time.Duration
}
LatencyStats contains aggregate latency data for a run.
type Result ¶
type Result struct {
Total int64
Failed int64
Duration time.Duration
RPS float64
Scheduled int64
Started int64
Dropped int64
DroppedRate float64
Completed int64
MaxActive int64
Latency LatencyStats
StatusCounts map[int]int64
ErrorCounts map[string]int64
Snapshots []Snapshot
// Buckets contains the raw histogram bucket counts (stats.NumBuckets = 800 values).
// Populated by Aggregator.Result() for use by distributed coordinators that need
// to merge per-worker histograms before computing cross-worker percentiles.
// Callers that only need latency percentiles can ignore this field.
Buckets []uint64
}
Result contains the aggregated execution metrics for a run.
type Snapshot ¶ added in v0.4.0
type Snapshot struct {
StartedAt time.Time
Duration time.Duration
Total int64
Failed int64
RPS float64
Scheduled int64
Started int64
Dropped int64
DroppedRate float64
Completed int64
MaxActive int64
Latency LatencyStats
StatusCounts map[int]int64
ErrorCounts map[string]int64
}
Snapshot contains metrics observed during one reporting interval. Scheduled, started, and dropped values are attributed when the arrival is handled. Completed requests and latency values are attributed when execution finishes.