histogram

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: BSD-3-Clause Imports: 4 Imported by: 8

Documentation

Overview

Package histogram implements a basic histogram to keep track of data distribution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Histogram

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

A Histogram accumulates values in the form of a histogram. The type of the values is int64, which is suitable for keeping track of things like RPC latency in milliseconds. New histogram objects should be obtained via the New() function.

func New

func New(opts Options) *Histogram

New returns a pointer to a new Histogram object that was created with the provided options.

func (*Histogram) Add

func (h *Histogram) Add(value int64) error

Add adds a value to the histogram.

func (*Histogram) Delta10m

func (h *Histogram) Delta10m() stats.HistogramValue

Delta10m returns the change in the last 10 minutes.

func (*Histogram) Delta1h

func (h *Histogram) Delta1h() stats.HistogramValue

Delta1h returns the change in the last hour.

func (*Histogram) Delta1m

func (h *Histogram) Delta1m() stats.HistogramValue

Delta1m returns the change in the last 10 minutes.

func (*Histogram) LastUpdate

func (h *Histogram) LastUpdate() time.Time

LastUpdate returns the time at which the object was last updated.

func (*Histogram) Opts

func (h *Histogram) Opts() Options

Opts returns a copy of the options used to create the Histogram.

func (*Histogram) Value

func (h *Histogram) Value() stats.HistogramValue

Value returns the accumulated state of the histogram since it was created.

type Options

type Options struct {
	// NumBuckets is the number of buckets.
	NumBuckets int
	// GrowthFactor is the growth factor of the buckets. A value of 0.1
	// indicates that bucket N+1 will be 10% larger than bucket N.
	GrowthFactor float64
	// SmallestBucketSize is the size of the first bucket. Bucket sizes are
	// rounded down to the nearest integer.
	SmallestBucketSize float64
	// MinValue is the lower bound of the first bucket.
	MinValue int64
}

Options contains the parameters that define the histogram's buckets.

Jump to

Keyboard shortcuts

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