datum

package
v3.0.0-rc26+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecIntBy

func DecIntBy(d Datum, v int64, ts time.Time)

DecIntBy increments an integer Datum by the provided value, at time ts, or panics if the Datum is not an IntDatum.

func GetBucketsByMax

func GetBucketsByMax(d Datum) map[float64]uint64

GetBucketsByMax returns a map of bucket observations by their upper bonds, or panics if d is not a BucketsDatum

func GetBucketsCount

func GetBucketsCount(d Datum) uint64

GetBucketCount returns the total count of observations in d, or panics if d is not a BucketsDatum

func GetBucketsSum

func GetBucketsSum(d Datum) float64

GetBucketsSum returns the sum of observations in d, or panics if d is not a BucketsDatum

func GetFloat

func GetFloat(d Datum) float64

GetFloat returns the floating-point value of a datum, or error.

func GetInt

func GetInt(d Datum) int64

GetInt returns the integer value of a datum, or error.

func GetString

func GetString(d Datum) string

GetString returns the string of a datum, or error.

func IncIntBy

func IncIntBy(d Datum, v int64, ts time.Time)

IncIntBy increments an integer Datum by the provided value, at time ts, or panics if the Datum is not an IntDatum.

func Observe

func Observe(d Datum, v float64, ts time.Time)

Observe records an observation v at time ts in d, or panics if d is not a BucketsDatum

func SetFloat

func SetFloat(d Datum, v float64, ts time.Time)

SetFloat sets a floating-point Datum to the provided value and timestamp, or panics if the Datum is not a FloatDatum.

func SetInt

func SetInt(d Datum, v int64, ts time.Time)

SetInt sets an integer datum to the provided value and timestamp, or panics if the Datum is not an IntDatum.

func SetString

func SetString(d Datum, v string, ts time.Time)

SetString sets a string Datum to the provided value and timestamp, or panics if the Datym is not a String Datum

Types

type BaseDatum

type BaseDatum struct {
	Time int64 // nanoseconds since unix epoch
}

BaseDatum is a struct used to record timestamps across all Datum implementations.

func (*BaseDatum) TimeString

func (d *BaseDatum) TimeString() string

TimeString returns the timestamp of this Datum as a string.

func (*BaseDatum) TimeUTC

func (d *BaseDatum) TimeUTC() time.Time

type BucketsDatum

type BucketsDatum struct {
	BaseDatum
	sync.RWMutex
	// contains filtered or unexported fields
}

BucketsDatum describes a floating point value at a given timestamp.

func GetBuckets

func GetBuckets(d Datum) *BucketsDatum

func (*BucketsDatum) AddBucket

func (d *BucketsDatum) AddBucket(r Range)

func (*BucketsDatum) Buckets

func (d *BucketsDatum) Buckets() map[Range]uint64

func (*BucketsDatum) Count

func (d *BucketsDatum) Count() uint64

func (*BucketsDatum) MarshalJSON

func (d *BucketsDatum) MarshalJSON() ([]byte, error)

func (*BucketsDatum) Observe

func (d *BucketsDatum) Observe(v float64, ts time.Time)

func (*BucketsDatum) String

func (d *BucketsDatum) String() string

func (*BucketsDatum) Sum

func (d *BucketsDatum) Sum() float64

func (*BucketsDatum) Type

func (*BucketsDatum) Type() Type

func (*BucketsDatum) ValueString

func (d *BucketsDatum) ValueString() string

type Datum

type Datum interface {
	// Type returns the Datum type.
	Type() Type

	// ValueString returns the value of a Datum as a string.
	ValueString() string

	// TimeString returns the timestamp of a Datum as a string.
	TimeString() string

	// Time returns the timestamp of the Datum as time.Time in UTC
	TimeUTC() time.Time
}

Datum is an interface for metric datums, with a type, value and timestamp to be exported.

func MakeBuckets

func MakeBuckets(buckets []Range, ts time.Time) Datum

MakeBuckets creates a new bucket datum with the provided list of ranges and timestamp. If no +inf bucket is provided, one is created.

func MakeFloat

func MakeFloat(v float64, ts time.Time) Datum

MakeFloat creates a new floating-point datum with the provided value and timestamp.

func MakeInt

func MakeInt(v int64, ts time.Time) Datum

MakeInt creates a new integer datum with the provided value and timestamp.

func MakeString

func MakeString(v string, ts time.Time) Datum

MakeString creates a new string datum with the provided value and timestamp

func NewBuckets

func NewBuckets(buckets []Range) Datum

NewBuckets creates a new zero buckets datum.

func NewFloat

func NewFloat() Datum

NewFloat creates a new zero floating-point datum.

func NewInt

func NewInt() Datum

NewInt creates a new zero integer datum.

func NewString

func NewString() Datum

NewString creates a new zero string datum.

type FloatDatum

type FloatDatum struct {
	BaseDatum
	Valuebits uint64
}

FloatDatum describes a floating point value at a given timestamp.

func (*FloatDatum) Get

func (d *FloatDatum) Get() float64

Get returns the floating-point value.

func (*FloatDatum) MarshalJSON

func (d *FloatDatum) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the FloatDatum.

func (*FloatDatum) Set

func (d *FloatDatum) Set(v float64, ts time.Time)

Set sets value of the FloatDatum at the timestamp ts.

func (*FloatDatum) String

func (d *FloatDatum) String() string

String returns a string representation of the FloatDatum.

func (*FloatDatum) Type

func (*FloatDatum) Type() Type

Type returns the Type of this Datum.

func (*FloatDatum) ValueString

func (d *FloatDatum) ValueString() string

ValueString returns the value of the FloatDatum as a string.

type IntDatum

type IntDatum struct {
	BaseDatum
	Value int64
}

IntDatum describes an integer value at a given timestamp.

func (*IntDatum) DecBy

func (d *IntDatum) DecBy(delta int64, timestamp time.Time)

DecBy increments the IntDatum's value by the value provided, at timestamp.

func (*IntDatum) Get

func (d *IntDatum) Get() int64

Get returns the value of the IntDatum

func (*IntDatum) IncBy

func (d *IntDatum) IncBy(delta int64, timestamp time.Time)

IncBy increments the IntDatum's value by the value provided, at timestamp.

func (*IntDatum) MarshalJSON

func (d *IntDatum) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the IntDatum.

func (*IntDatum) Set

func (d *IntDatum) Set(value int64, timestamp time.Time)

Set sets the value of the IntDatum to the value at timestamp.

func (*IntDatum) String

func (d *IntDatum) String() string

String returns a string representation of the IntDatum.

func (*IntDatum) Type

func (*IntDatum) Type() Type

Type returns the Type of an IntDatum, Int.

func (*IntDatum) ValueString

func (d *IntDatum) ValueString() string

ValueString returns the value of the IntDatum as a string.

type Range

type Range struct {
	Min float64
	Max float64
}

func (*Range) Contains

func (r *Range) Contains(v float64) bool

type StringDatum

type StringDatum struct {
	BaseDatum

	Value string
	// contains filtered or unexported fields
}

StringDatum describes a string value at a given timestamp.

func (*StringDatum) Get

func (d *StringDatum) Get() string

Get returns the value of the StringDatum

func (*StringDatum) MarshalJSON

func (d *StringDatum) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the StringDatum.

func (*StringDatum) Set

func (d *StringDatum) Set(value string, timestamp time.Time)

Set sets the value of the StringDatum to the value at timestamp.

func (*StringDatum) String

func (d *StringDatum) String() string

String returns a string representation of the StringDatum.

func (*StringDatum) Type

func (*StringDatum) Type() Type

Type returns the Type of an StringDatum, String.

func (*StringDatum) ValueString

func (d *StringDatum) ValueString() string

ValueString returns the value of the StringDatum as a string.

type Type

type Type int

Type describes the type of value stored in a Datum.

const (
	// Int describes an integer datum
	Int Type = iota
	// Float describes a floating point datum
	Float
	// String describes printable strings of text
	String
	// Buckets describes histograms
	Buckets
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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