datapoint

package
v3.3.43 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMaps

func AddMaps(a, b map[string]string) map[string]string

AddMaps adds two maps of dimensions and returns a new map of dimensions that is a + b. Note that b takes precedent. Works with nil or empty a/b maps. Does not modify either map, but may return a or b if the other is empty.

Types

type Datapoint

type Datapoint struct {
	// What is being measured.  We think metric, rather than "unit" of metrics20, should be the
	// required identity of a datapoint and the "unit" should be a property of the Value itself
	Metric string `json:"metric"`
	// Dimensions of what is being measured.  They are intrinsic.  Contributes to the identity of
	// the metric. If this changes, we get a new metric identifier
	Dimensions map[string]string `json:"dimensions"`
	// Meta is information that's not particularly important to the datapoint, but may be important
	// to the pipeline that uses the datapoint.  They are extrinsic.  It provides additional
	// information about the metric. changes in this set doesn't change the metric identity
	Meta map[interface{}]interface{} `json:"-"`
	// Value of the datapoint
	Value Value `json:"value"`
	// The type of the datapoint series
	MetricType MetricType `json:"metric_type"`
	// The unix time of the datapoint
	Timestamp time.Time `json:"timestamp"`
}

A Datapoint is the metric that is saved. Designed around http://metrics20.org/spec/

func New

func New(metric string, dimensions map[string]string, value Value, metricType MetricType, timestamp time.Time) *Datapoint

New creates a new datapoint with empty meta data

func NewWithMeta

func NewWithMeta(metric string, dimensions map[string]string, meta map[interface{}]interface{}, value Value, metricType MetricType, timestamp time.Time) *Datapoint

NewWithMeta creates a new datapoint with passed metadata

func (*Datapoint) GetProperties

func (dp *Datapoint) GetProperties() map[string]interface{}

GetProperties gets the map of properties to set when creating the time series associated with the datapoint. nil if no properties are set.

func (*Datapoint) RemoveProperty

func (dp *Datapoint) RemoveProperty(key string)

RemoveProperty removes a property from the map of properties to be used when the time series associated with the datapoint is created

func (*Datapoint) SetProperty

func (dp *Datapoint) SetProperty(key string, value interface{})

SetProperty sets a property to be used when the time series associated with the datapoint is created

func (*Datapoint) String

func (dp *Datapoint) String() string

func (*Datapoint) UnmarshalJSON

func (dp *Datapoint) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes JSON into a datapoint, creating the correct Value interface types for the type of JSON value that was encoded

type FloatValue

type FloatValue interface {
	Value
	Float() float64
}

FloatValue are values that represent an exact floating point value.

func NewFloatValue

func NewFloatValue(val float64) FloatValue

NewFloatValue creates new datapoint value is a float

type IntValue

type IntValue interface {
	Value
	Int() int64
}

IntValue are values that represent an exact integer point value.

func NewIntValue

func NewIntValue(val int64) IntValue

NewIntValue creates new datapoint value is an integer

type MetricType

type MetricType int

MetricType define how to display the Value. It's more metadata of the series than data about the series itself. See target_type of http://metrics20.org/spec/

const (
	// Gauge is values at each point in time
	Gauge MetricType = iota
	// Count is a number per a given interval (such as a statsd flushInterval); not very useful
	Count
	// Enum is an added type: Values aren't important relative to each other but are just important as distinct
	// items in a set.  Usually used when Value is type "string"
	Enum
	// Counter is a number that keeps increasing over time (but might wrap/reset at some points)
	// (no statsd counterpart), i.e. a gauge with the added notion of "i usually want to derive this"
	Counter
	// Rate is a number per second
	Rate
	// Timestamp value represents a unix timestamp
	Timestamp
)

func (MetricType) String

func (mt MetricType) String() string

func (*MetricType) UnmarshalJSON

func (mt *MetricType) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes JSON number as a MetricType

func (*MetricType) UnmarshalText

func (mt *MetricType) UnmarshalText(text []byte) error

UnmarshalText decodes text as a MetricType in a case-insensitive way

type StringValue

type StringValue interface {
	Value
}

StringValue are values that represent an exact string value and don't have a numeric representation.

func NewStringValue

func NewStringValue(val string) StringValue

NewStringValue creates new datapoint value is a string

type Value

type Value interface {
	fmt.Stringer
}

A Value is the value being sent between servers. It is usually a floating point but different systems support different types of values. All values must be printable in some human readable interface

func CastFloatValue

func CastFloatValue(value interface{}) (metricValue Value, err error)

CastFloatValue casts a float to datapoint Value

func CastIntegerValue

func CastIntegerValue(value interface{}) (metricValue Value, err error)

CastIntegerValue casts a signed integer to a datapoint Value

func CastMetricValue

func CastMetricValue(value interface{}) (metricValue Value, err error)

CastMetricValue casts an interface to datapoint Value

func CastMetricValueWithBool

func CastMetricValueWithBool(value interface{}) (metricValue Value, err error)

CastMetricValueWithBool casts an interface to datapoint Value and handles bool

func CastUIntegerValue

func CastUIntegerValue(value interface{}) (metricValue Value, err error)

CastUIntegerValue casts an unsigned integer to a datapoint Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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