bucket

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyBuckets = fmt.Errorf("time range produces more than %d buckets", maxBuckets)

ErrTooManyBuckets is returned when the granularity + time range would produce more than maxBuckets time slots, which could cause OOM.

Functions

func AdvanceTime

func AdvanceTime(t time.Time, g *driver.Granularity) time.Time

AdvanceTime steps forward by one granularity unit from t.

func FillAttemptBuckets

FillAttemptBuckets fills in missing time buckets with zero-valued data points. Returns ErrTooManyBuckets if the time range + granularity produces too many slots.

func FillEventBuckets

FillEventBuckets fills in missing time buckets with zero-valued data points so that the response contains one entry per time slot (per dimension combo). Returns ErrTooManyBuckets if the time range + granularity produces too many slots.

func GenerateTimeBuckets

func GenerateTimeBuckets(start, end time.Time, g *driver.Granularity) ([]time.Time, error)

GenerateTimeBuckets returns a slice of aligned time slots from the truncated start up to (but not including) end, stepping by one granularity unit. Returns ErrTooManyBuckets if the result would exceed maxBuckets.

func TruncateTime

func TruncateTime(t time.Time, g *driver.Granularity) time.Time

TruncateTime truncates t to the boundary defined by granularity g. This is the shared implementation used by all backends.

For sub-day units (s, m, h), Value controls both step size and alignment. For calendar units (d, w, M), Value > 1 uses epoch-anchored alignment so that multi-day/week/month intervals aggregate data correctly.

Types

type DimKey

type DimKey string

DimKey is an opaque composite key built from dimension values.

func AttemptDimKey

func AttemptDimKey(dp *driver.AttemptMetricsDataPoint, dims []string) DimKey

AttemptDimKey builds a composite key from the dimension fields of an attempt data point.

func EventDimKey

func EventDimKey(dp *driver.EventMetricsDataPoint, dims []string) DimKey

EventDimKey builds a composite key from the dimension fields of an event data point.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL