Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertProtoAttributeMap(in map[string]*proto.Attribute) map[string]*Attribute
- func ConvertStructAttributeMap(in map[string]*Attribute) map[string]*proto.Attribute
- func ConvertStructStatObject(in *StatObject) *proto.StatObject
- func ConvertStructStatValue(in *StatValue) *proto.StatValue
- func ConvertStructsAttribute(in *Attribute) *proto.Attribute
- func CopyMapStringAttribute(in map[string]*Attribute) map[string]*Attribute
- func Pow(a, b int64) int64
- func ReattachConfigToGoPlugin(rc *ReattachConfig) (*plugin.ReattachConfig, error)
- type Attribute
- func ConvertProtoAttribute(in *proto.Attribute) *Attribute
- func NewBoolAttribute(b bool) *Attribute
- func NewFloatAttribute(f float64, unit string) *Attribute
- func NewIntAttribute(i int64, unit string) *Attribute
- func NewStringAttribute(s string) *Attribute
- func ParseAttribute(input string) *Attribute
- func (a *Attribute) Comparable(b *Attribute) bool
- func (a *Attribute) Compare(b *Attribute) (int, bool)
- func (a *Attribute) Copy() *Attribute
- func (a *Attribute) GetBool() (value bool, ok bool)
- func (a *Attribute) GetFloat() (value float64, ok bool)
- func (a *Attribute) GetInt() (value int64, ok bool)
- func (a *Attribute) GetString() (value string, ok bool)
- func (a *Attribute) GoString() string
- func (a *Attribute) Validate() error
- type BaseUnit
- type ReattachConfig
- type StatObject
- type StatValue
- type Unit
Constants ¶
const ( // Binary SI Byte Units UnitKiB = "KiB" UnitMiB = "MiB" UnitGiB = "GiB" UnitTiB = "TiB" UnitPiB = "PiB" UnitEiB = "EiB" // Decimal SI Byte Units UnitkB = "kB" UnitKB = "KB" UnitMB = "MB" UnitGB = "GB" UnitTB = "TB" UnitPB = "PB" UnitEB = "EB" // Binary SI Byte Rates UnitKiBPerS = "KiB/s" UnitMiBPerS = "MiB/s" UnitGiBPerS = "GiB/s" UnitTiBPerS = "TiB/s" UnitPiBPerS = "PiB/s" UnitEiBPerS = "EiB/s" // Decimal SI Byte Rates UnitkBPerS = "kB/s" UnitKBPerS = "KB/s" UnitMBPerS = "MB/s" UnitGBPerS = "GB/s" UnitTBPerS = "TB/s" UnitPBPerS = "PB/s" UnitEBPerS = "EB/s" // Hertz units UnitMHz = "MHz" UnitGHz = "GHz" // Watts units UnitmW = "mW" UnitW = "W" UnitkW = "kW" UnitMW = "MW" UnitGW = "GW" )
Variables ¶
var ( // UnitIndex is a map of unit name to unit UnitIndex = make(map[string]*Unit, numUnits) )
Functions ¶
func ConvertStructStatObject ¶
func ConvertStructStatObject(in *StatObject) *proto.StatObject
ConvertStructStatObject converts between a struct and proto StatObject
func ConvertStructStatValue ¶
ConvertStructStatValue converts between a struct and proto StatValue
func ConvertStructsAttribute ¶
func CopyMapStringAttribute ¶
CopyMapStringAttribute copies a map of string to Attribute
func ReattachConfigToGoPlugin ¶
func ReattachConfigToGoPlugin(rc *ReattachConfig) (*plugin.ReattachConfig, error)
ReattachConfigToGoPlugin converts a ReattachConfig wrapper struct into a go plugin ReattachConfig struct
Types ¶
type Attribute ¶
type Attribute struct { // Float is the float value for the attribute Float *float64 // Int is the int value for the attribute Int *int64 // String is the string value for the attribute String *string // Bool is the bool value for the attribute Bool *bool // Unit is the optional unit for the set int or float value Unit string }
Attribute is used to describe the value of an attribute, optionally specifying units
func ConvertProtoAttribute ¶
func NewBoolAttribute ¶
NewBoolAttribute returns a new boolean attribute.
func NewFloatAttribute ¶
NewFloatAttribute returns a new float attribute. The unit is not checked to be valid.
func NewIntAttribute ¶
NewIntAttribute returns a new integer attribute. The unit is not checked to be valid.
func NewStringAttribute ¶
NewStringAttribute returns a new string attribute.
func ParseAttribute ¶
ParseAttribute takes a string and parses it into an attribute, pulling out units if they are specified as a suffix on a number.
func (*Attribute) Comparable ¶
Comparable returns whether the two attributes are comparable
func (*Attribute) Compare ¶
Compare compares two attributes. If the returned boolean value is false, it means the values are not comparable, either because they are of different types (bool versus int) or the units are incompatible for comparison. The returned int will be 0 if a==b, -1 if a < b, and +1 if a > b for all values but bool. For bool it will be 0 if a==b or 1 if a!=b.
func (*Attribute) GetBool ¶
GetBool returns the boolean value of the attribute or false if the attribute doesn't contain a boolean.
func (*Attribute) GetFloat ¶
GetFloat returns the float value of the attribute or false if the attribute doesn't contain a float.
func (*Attribute) GetInt ¶
GetInt returns the integer value of the attribute or false if the attribute doesn't contain a integer.
func (*Attribute) GetString ¶
GetString returns the string value of the attribute or false if the attribute doesn't contain a string.
type BaseUnit ¶
type BaseUnit uint16
BaseUnit is a unique base unit. All units that share the same base unit should be comparable.
type ReattachConfig ¶
ReattachConfig is a wrapper around plugin.ReattachConfig to better support serialization
func ReattachConfigFromGoPlugin ¶
func ReattachConfigFromGoPlugin(plug *plugin.ReattachConfig) *ReattachConfig
ReattachConfigFromGoPlugin converts a go plugin ReattachConfig into a ReattachConfig wrapper struct
type StatObject ¶
type StatObject struct { // Nested is a mapping of object name to a nested stats object. Nested map[string]*StatObject // Attributes is a mapping of statistic name to its value. Attributes map[string]*StatValue }
StatObject is a collection of statistics either exposed at the top level or via nested StatObjects.
func ConvertProtoStatObject ¶
func ConvertProtoStatObject(in *proto.StatObject) *StatObject
ConvertProtoStatObject converts between a proto and struct StatObject
type StatValue ¶
type StatValue struct { // FloatNumeratorVal exposes a floating point value. If denominator is set // it is assumed to be a fractional value, otherwise it is a scalar. FloatNumeratorVal *float64 `json:",omitempty"` FloatDenominatorVal *float64 `json:",omitempty"` // IntNumeratorVal exposes a int value. If denominator is set it is assumed // to be a fractional value, otherwise it is a scalar. IntNumeratorVal *int64 `json:",omitempty"` IntDenominatorVal *int64 `json:",omitempty"` // StringVal exposes a string value. These are likely annotations. StringVal *string `json:",omitempty"` // BoolVal exposes a boolean statistic. BoolVal *bool `json:",omitempty"` // Unit gives the unit type: °F, %, MHz, MB, etc. Unit string `json:",omitempty"` // Desc provides a human readable description of the statistic. Desc string `json:",omitempty"` }
StatValue exposes the values of a particular statistic. The value may be of type float, integer, string or boolean. Numeric types can be exposed as a single value or as a fraction.
func ConvertProtoStatValue ¶
ConvertProtoStatValue converts between a proto and struct StatValue
type Unit ¶
type Unit struct { // Name is the name of the unit (GiB, MB/s) Name string // Base is the base unit for the unit Base BaseUnit // Multiplier is the multiplier over the base unit (KiB multiplier is 1024) Multiplier int64 // InverseMultiplier specifies that the multiplier is an inverse so: // Base / Multiplier. For example a mW is a W/1000. InverseMultiplier bool }
Unit describes a unit and its multiplier over the base unit type
func (*Unit) Comparable ¶
Comparable returns if two units are comparable