Help us shape the future of Go! Take the 2026 Go Developer Survey

chunk

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 99

Documentation

Index

Constants

View Source
const BatchSize = 12

BatchSize is samples per batch; this was choose by benchmarking all sizes from 1 to 128.

Variables

View Source
var BenchmarkLabels = labels.FromStrings(
	model.MetricNameLabel, "container_cpu_usage_seconds_total",
	"beta_kubernetes_io_arch", "amd64",
	"beta_kubernetes_io_instance_type", "c3.somesize",
	"beta_kubernetes_io_os", "linux",
	"container_name", "some-name",
	"cpu", "cpu01",
	"failure_domain_beta_kubernetes_io_region", "somewhere-1",
	"failure_domain_beta_kubernetes_io_zone", "somewhere-1b",
	"id", "/kubepods/burstable/pod6e91c467-e4c5-11e7-ace3-0a97ed59c75e/a3c8498918bd6866349fed5a6f8c643b77c91836427fb6327913276ebc6bde28",
	"image", "registry/organisation/name@sha256:dca3d877a80008b45d71d7edc4fd2e44c0c8c8e7102ba5cbabec63a374d1d506",
	"instance", "ip-111-11-1-11.ec2.internal",
	"job", "kubernetes-cadvisor",
	"kubernetes_io_hostname", "ip-111-11-1-11",
	"monitor", "prod",
	"name", "k8s_some-name_some-other-name-5j8s8_kube-system_6e91c467-e4c5-11e7-ace3-0a97ed59c75e_0",
	"namespace", "kube-system",
	"pod_name", "some-other-name-5j8s8",
)

BenchmarkLabels is a real example from Kubernetes' embedded cAdvisor metrics, lightly obfuscated

Functions

func DecodeLabels added in v1.20.0

func DecodeLabels(ptr unsafe.Pointer, iter *jsoniter.Iterator)

Override Prometheus' labels.Labels decoder which goes via a map

func EncodeLabels added in v1.20.0

func EncodeLabels(ptr unsafe.Pointer, stream *jsoniter.Stream)

Override Prometheus' labels.Labels encoder which goes via a map

Types

type Batch added in v1.18.0

type Batch struct {
	Timestamps      [BatchSize]int64
	Values          [BatchSize]float64
	Histograms      [BatchSize]*histogram.Histogram
	FloatHistograms [BatchSize]*histogram.FloatHistogram
	Index           int
	Length          int
	ValType         chunkenc.ValueType
}

Batch is a sorted set of (timestamp, value) pairs. They are intended to be small, and passed by value. Value can vary depending on the chunk value type.

type Chunk

type Chunk struct {
	// These fields will be in all chunks, including old ones.
	From    model.Time     `json:"from"`
	Through model.Time     `json:"through"`
	Metric  labels.Labels  `json:"metric"`
	Data    chunkenc.Chunk `json:"-"`
}

Chunk contains encoded timeseries data

func NewChunk

func NewChunk(metric labels.Labels, c chunkenc.Chunk, from, through model.Time) Chunk

NewChunk creates a new chunk

func (*Chunk) NewIterator added in v1.18.0

func (c *Chunk) NewIterator(iterator Iterator) Iterator

type Iterator added in v1.18.0

type Iterator interface {
	// Scans the next value in the chunk. Directly after the iterator has
	// been created, the next value is the first value in the
	// chunk. Otherwise, it is the value following the last value scanned or
	// found (by one of the Find... methods). Returns chunkenc.ValNoe if either
	// the end of the chunk is reached or an error has occurred.
	Scan() chunkenc.ValueType
	// Finds the oldest value at or after the provided time and returns the value type.
	// Returns chunkenc.ValNone if either the chunk contains no value at or after
	// the provided time, or an error has occurred.
	FindAtOrAfter(model.Time) chunkenc.ValueType
	// Returns a batch of the provisded size; NB not idempotent!  Should only be called
	// once per Scan.
	Batch(size int, valType chunkenc.ValueType) Batch
	// Returns the last error encountered. In general, an error signals data
	// corruption in the chunk and requires quarantining.
	Err() error
}

Iterator enables efficient access to the content of a chunk. It is generally not safe to use an Iterator concurrently with or after chunk mutation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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