Documentation
¶
Overview ¶
Package speed implements a golang client for the Performance Co-Pilot instrumentation API.
It is based on the C/Perl/Python API implemented in PCP core as well as the Java API implemented by `parfait`, a separate project.
Some examples on using the API are implemented as executable go programs in the `examples` subdirectory.
Index ¶
- Constants
- Variables
- type Client
- type CountUnit
- type Counter
- type CounterVector
- type Gauge
- type GaugeVector
- type Histogram
- type HistogramBucket
- type InstanceDomain
- type InstanceMetric
- type Instances
- type MMVFlag
- type Metric
- type MetricSemantics
- type MetricType
- type MetricUnit
- type PCPClient
- func (c *PCPClient) Length() int
- func (c *PCPClient) MustRegister(m Metric)
- func (c *PCPClient) MustRegisterIndom(indom InstanceDomain)
- func (c *PCPClient) MustRegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) Metric
- func (c *PCPClient) MustStart()
- func (c *PCPClient) MustStop()
- func (c *PCPClient) Register(m Metric) error
- func (c *PCPClient) RegisterIndom(indom InstanceDomain) error
- func (c *PCPClient) RegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)
- func (c *PCPClient) Registry() Registry
- func (c *PCPClient) SetFlag(flag MMVFlag) error
- func (c *PCPClient) Start() error
- func (c *PCPClient) Stop() error
- type PCPCounter
- type PCPCounterVector
- func (c *PCPCounterVector) Inc(inc int64, instance string) error
- func (c *PCPCounterVector) IncAll(val int64)
- func (m PCPCounterVector) Indom() *PCPInstanceDomain
- func (m PCPCounterVector) Instances() []string
- func (c *PCPCounterVector) MustInc(inc int64, instance string)
- func (c *PCPCounterVector) MustSet(val int64, instance string)
- func (c *PCPCounterVector) Set(val int64, instance string) error
- func (c *PCPCounterVector) SetAll(val int64)
- func (c *PCPCounterVector) Up(instance string)
- func (c *PCPCounterVector) UpAll()
- func (c *PCPCounterVector) Val(instance string) (int64, error)
- type PCPGauge
- func (g *PCPGauge) Dec(val float64) error
- func (g *PCPGauge) Inc(val float64) error
- func (m PCPGauge) Indom() *PCPInstanceDomain
- func (g *PCPGauge) MustDec(val float64)
- func (g *PCPGauge) MustInc(val float64)
- func (g *PCPGauge) MustSet(val float64)
- func (g *PCPGauge) Set(val float64) error
- func (g *PCPGauge) Val() float64
- type PCPGaugeVector
- func (g *PCPGaugeVector) Dec(inc float64, instance string) error
- func (g *PCPGaugeVector) DecAll(val float64)
- func (g *PCPGaugeVector) Inc(inc float64, instance string) error
- func (g *PCPGaugeVector) IncAll(val float64)
- func (m PCPGaugeVector) Indom() *PCPInstanceDomain
- func (m PCPGaugeVector) Instances() []string
- func (g *PCPGaugeVector) MustDec(inc float64, instance string)
- func (g *PCPGaugeVector) MustInc(inc float64, instance string)
- func (g *PCPGaugeVector) MustSet(val float64, instance string)
- func (g *PCPGaugeVector) Set(val float64, instance string) error
- func (g *PCPGaugeVector) SetAll(val float64)
- func (g *PCPGaugeVector) Val(instance string) (float64, error)
- type PCPHistogram
- func (h *PCPHistogram) Buckets() []*HistogramBucket
- func (h *PCPHistogram) High() int64
- func (m PCPHistogram) Indom() *PCPInstanceDomain
- func (m PCPHistogram) Instances() []string
- func (h *PCPHistogram) Low() int64
- func (h *PCPHistogram) Max() int64
- func (h *PCPHistogram) Mean() float64
- func (h *PCPHistogram) Min() int64
- func (h *PCPHistogram) MustRecord(val int64)
- func (h *PCPHistogram) MustRecordN(val, n int64)
- func (h *PCPHistogram) Percentile(p float64) int64
- func (h *PCPHistogram) Record(val int64) error
- func (h *PCPHistogram) RecordN(val, n int64) error
- func (h *PCPHistogram) StandardDeviation() float64
- func (h *PCPHistogram) Variance() float64
- type PCPInstanceDomain
- func (indom *PCPInstanceDomain) Description() string
- func (indom *PCPInstanceDomain) HasInstance(name string) bool
- func (indom *PCPInstanceDomain) ID() uint32
- func (indom *PCPInstanceDomain) InstanceCount() int
- func (indom *PCPInstanceDomain) Instances() []string
- func (indom *PCPInstanceDomain) MatchInstances(ins []string) bool
- func (indom *PCPInstanceDomain) Name() string
- func (indom *PCPInstanceDomain) String() string
- type PCPInstanceMetric
- func (m PCPInstanceMetric) Indom() *PCPInstanceDomain
- func (m PCPInstanceMetric) Instances() []string
- func (m *PCPInstanceMetric) MustSetInstance(val interface{}, instance string)
- func (m *PCPInstanceMetric) SetInstance(val interface{}, instance string) error
- func (m *PCPInstanceMetric) ValInstance(instance string) (interface{}, error)
- type PCPMetric
- type PCPRegistry
- func (r *PCPRegistry) AddInstanceDomain(indom InstanceDomain) error
- func (r *PCPRegistry) AddInstanceDomainByName(name string, instances []string) (InstanceDomain, error)
- func (r *PCPRegistry) AddMetric(m Metric) error
- func (r *PCPRegistry) AddMetricByString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)
- func (r *PCPRegistry) HasInstanceDomain(name string) bool
- func (r *PCPRegistry) HasMetric(name string) bool
- func (r *PCPRegistry) InstanceCount() int
- func (r *PCPRegistry) InstanceDomainCount() int
- func (r *PCPRegistry) MetricCount() int
- func (r *PCPRegistry) StringCount() int
- func (r *PCPRegistry) ValuesCount() int
- type PCPSingletonMetric
- type PCPTimer
- type Registry
- type SingletonMetric
- type SpaceUnit
- type TimeUnit
- type Timer
Constants ¶
const ( HeaderLength = 40 TocLength = 16 Metric1Length = 104 Metric2Length = 48 ValueLength = 32 Instance1Length = 80 Instance2Length = 24 InstanceDomainLength = 32 StringLength = 256 )
byte lengths of different components in an mmv file
const ( HistogramMin = 0 HistogramMax = 3600000000 )
the maximum and minimum values that can be recorded by a histogram
const MaxDataValueSize = 16
MaxDataValueSize is the maximum byte length for a stored metric value, unless it is a string
const MaxV1NameLength = 63
MaxV1NameLength is the maximum length for a metric/instance name under MMV format 1
const PCPClusterIDBitLength = 12
PCPClusterIDBitLength is the bit length of the cluster id for a set of PCP metrics
const PCPInstanceDomainBitLength = 22
PCPInstanceDomainBitLength is the maximum bit length of a PCP Instance Domain
see: https://github.com/performancecopilot/pcp/blob/master/src/include/pcp/impl.h#L102-L121
const PCPMetricItemBitLength = 10
PCPMetricItemBitLength is the maximum bit size of a PCP Metric id.
see: https://github.com/performancecopilot/pcp/blob/master/src/include/pcp/impl.h#L102-L121
const Version = "3.0.0"
Version is the last tagged version of the package
Variables ¶
var EraseFileOnStop = false
EraseFileOnStop if set to true, will also delete the memory mapped file
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // a client must contain a registry of metrics Registry() Registry // starts monitoring Start() error // Start that will panic on failure MustStart() // stop monitoring Stop() error // Stop that will panic on failure MustStop() // adds a metric to be monitored Register(Metric) error // tries to add a metric to be written and panics on error MustRegister(Metric) // adds metric from a string RegisterString(string, interface{}, MetricType, MetricSemantics, MetricUnit) (Metric, error) // tries to add a metric from a string and panics on an error MustRegisterString(string, interface{}, MetricType, MetricSemantics, MetricUnit) Metric }
Client defines the interface for a type that can talk to an instrumentation agent
type CountUnit ¶
type CountUnit uint32
CountUnit is a type representing a counted quantity.
OneUnit represents the only CountUnit. For count units bits 8-11 are 1 and bits 21-24 are scale.
func (CountUnit) Count ¶
func (c CountUnit) Count(CountUnit, int8) MetricUnit
Count adds a count unit to the current unit at a specific dimension
type Counter ¶
type Counter interface { Metric Val() int64 Set(int64) error Inc(int64) error MustInc(int64) Up() // same as MustInc(1) }
Counter defines a metric that holds a single value that can only be incremented.
type CounterVector ¶
type CounterVector interface { Metric Val(string) (int64, error) Set(int64, string) error MustSet(int64, string) SetAll(int64) Inc(int64, string) error MustInc(int64, string) IncAll(int64) Up(string) UpAll() }
CounterVector defines a Counter on multiple instances.
type Gauge ¶
type Gauge interface { Metric Val() float64 Set(float64) error MustSet(float64) Inc(float64) error Dec(float64) error MustInc(float64) MustDec(float64) }
Gauge defines a metric that holds a single double value that can be incremented or decremented.
type GaugeVector ¶
type GaugeVector interface { Metric Val(string) (float64, error) Set(float64, string) error MustSet(float64, string) SetAll(float64) Inc(float64, string) error MustInc(float64, string) IncAll(float64) Dec(float64, string) error MustDec(float64, string) DecAll(float64) }
GaugeVector defines a Gauge on multiple instances
type Histogram ¶
type Histogram interface { Max() int64 // Maximum value recorded so far Min() int64 // Minimum value recorded so far High() int64 // Highest allowed value Low() int64 // Lowest allowed value Record(int64) error // Records a new value RecordN(int64, int64) error // Records multiple instances of the same value MustRecord(int64) MustRecordN(int64, int64) Mean() float64 // Mean of all recorded data Variance() float64 // Variance of all recorded data StandardDeviation() float64 // StandardDeviation of all recorded data Percentile(float64) int64 // Percentile returns the value at the passed percentile }
Histogram defines a metric that records a distribution of data
type HistogramBucket ¶
type HistogramBucket struct {
From, To, Count int64
}
HistogramBucket is a single histogram bucket within a fixed range.
type InstanceDomain ¶
type InstanceDomain interface { ID() uint32 // unique identifier for the instance domain Name() string // name of the instance domain Description() string // description for the instance domain HasInstance(name string) bool // checks if an instance is in the indom InstanceCount() int // returns the number of instances in the indom Instances() []string // returns a slice of instances in the instance domain }
InstanceDomain defines the interface for an instance domain
type InstanceMetric ¶
type InstanceMetric interface { Metric // gets the value of a particular instance ValInstance(string) (interface{}, error) // sets the value of a particular instance SetInstance(interface{}, string) error // tries to set the value of a particular instance and panics on error MustSetInstance(interface{}, string) // returns a slice containing all instances in the metric Instances() []string }
InstanceMetric defines the interface for a metric that stores multiple values in instances and instance domains.
type Instances ¶
type Instances map[string]interface{}
Instances defines a valid collection of instance name and values
type Metric ¶
type Metric interface { // gets the unique id generated for this metric ID() uint32 // gets the name for the metric Name() string // gets the type of a metric Type() MetricType // gets the unit of a metric Unit() MetricUnit // gets the semantics for a metric Semantics() MetricSemantics // gets the description of a metric Description() string }
Metric defines the general interface a type needs to implement to qualify as a valid PCP metric.
type MetricSemantics ¶
type MetricSemantics int32
MetricSemantics represents an enumerated type representing the possible values for the semantics of a metric.
const ( NoSemantics MetricSemantics = iota CounterSemantics InstantSemantics DiscreteSemantics )
Possible values for MetricSemantics.
func (MetricSemantics) String ¶
func (i MetricSemantics) String() string
type MetricType ¶
type MetricType int32
MetricType is an enumerated type representing all valid types for a metric.
const ( Int32Type MetricType = iota Uint32Type Int64Type Uint64Type FloatType DoubleType StringType )
Possible values for a MetricType.
func (MetricType) IsCompatible ¶
func (m MetricType) IsCompatible(val interface{}) bool
IsCompatible checks if the passed value is compatible with the current MetricType.
func (MetricType) String ¶
func (i MetricType) String() string
type MetricUnit ¶
type MetricUnit interface { fmt.Stringer // return 32 bit PMAPI representation for the unit // see: https://github.com/performancecopilot/pcp/blob/master/src/include/pcp/pmapi.h#L61-L101 PMAPI() uint32 // add a space unit to the current unit at a specific dimension Space(SpaceUnit, int8) MetricUnit // add a time unit to the current unit at a specific dimension Time(TimeUnit, int8) MetricUnit // add a count unit to the current unit at a specific dimension Count(CountUnit, int8) MetricUnit }
MetricUnit defines the interface for a unit type for speed.
func NewMetricUnit ¶
func NewMetricUnit() MetricUnit
NewMetricUnit returns a new object for initialization
type PCPClient ¶
type PCPClient struct {
// contains filtered or unexported fields
}
PCPClient implements a client that can generate instrumentation for PCP
func NewPCPClient ¶
NewPCPClient initializes a new PCPClient object
func NewPCPClientWithRegistry ¶
func NewPCPClientWithRegistry(name string, registry *PCPRegistry) (*PCPClient, error)
NewPCPClientWithRegistry initializes a new PCPClient object with the given registry
func (*PCPClient) Length ¶
Length returns the byte length of data in the mmv file written by the current writer
func (*PCPClient) MustRegister ¶
MustRegister is simply a Register that can panic
func (*PCPClient) MustRegisterIndom ¶
func (c *PCPClient) MustRegisterIndom(indom InstanceDomain)
MustRegisterIndom is simply a RegisterIndom that can panic
func (*PCPClient) MustRegisterString ¶
func (c *PCPClient) MustRegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) Metric
MustRegisterString is simply a RegisterString that panics
func (*PCPClient) RegisterIndom ¶
func (c *PCPClient) RegisterIndom(indom InstanceDomain) error
RegisterIndom is simply a shorthand for Registry().AddInstanceDomain
func (*PCPClient) RegisterString ¶
func (c *PCPClient) RegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)
RegisterString is simply a shorthand for Registry().AddMetricByString
type PCPCounter ¶
type PCPCounter struct {
// contains filtered or unexported fields
}
PCPCounter implements a PCP compatible Counter Metric.
func NewPCPCounter ¶
func NewPCPCounter(val int64, name string, desc ...string) (*PCPCounter, error)
NewPCPCounter creates a new PCPCounter instance. It requires an initial int64 value and a metric name for construction. optionally it can also take a couple of description strings that are used as short and long descriptions respectively. Internally it creates a PCP SingletonMetric with Int64Type, CounterSemantics and CountUnit.
func (*PCPCounter) Inc ¶
func (c *PCPCounter) Inc(val int64) error
Inc increases the stored counter's value by the passed increment.
func (PCPCounter) Indom ¶
func (m PCPCounter) Indom() *PCPInstanceDomain
func (*PCPCounter) MustInc ¶
func (c *PCPCounter) MustInc(val int64)
MustInc is Inc that panics on failure.
func (*PCPCounter) Set ¶
func (c *PCPCounter) Set(val int64) error
Set sets the value of the counter.
func (*PCPCounter) Val ¶
func (c *PCPCounter) Val() int64
Val returns the current value of the counter.
type PCPCounterVector ¶
type PCPCounterVector struct {
// contains filtered or unexported fields
}
PCPCounterVector implements a CounterVector
func NewPCPCounterVector ¶
func NewPCPCounterVector(values map[string]int64, name string, desc ...string) (*PCPCounterVector, error)
NewPCPCounterVector creates a new instance of a PCPCounterVector. it requires a metric name and a set of instance names and values as a map. it can optionally accept a couple of strings as short and long descriptions of the metric. Internally it uses a PCP InstanceMetric with Int64Type, CounterSemantics and CountUnit.
func (*PCPCounterVector) Inc ¶
func (c *PCPCounterVector) Inc(inc int64, instance string) error
Inc increments the value of a particular instance of PCPCounterVector.
func (*PCPCounterVector) IncAll ¶
func (c *PCPCounterVector) IncAll(val int64)
IncAll increments all instances by the same value and panics on an error.
func (PCPCounterVector) Indom ¶
func (m PCPCounterVector) Indom() *PCPInstanceDomain
Indom returns the instance domain for the metric.
func (PCPCounterVector) Instances ¶
func (m PCPCounterVector) Instances() []string
Instances returns a slice containing all instances in the InstanceMetric. Basically a shorthand for metric.Indom().Instances().
func (*PCPCounterVector) MustInc ¶
func (c *PCPCounterVector) MustInc(inc int64, instance string)
MustInc panics if Inc fails.
func (*PCPCounterVector) MustSet ¶
func (c *PCPCounterVector) MustSet(val int64, instance string)
MustSet panics if Set fails.
func (*PCPCounterVector) Set ¶
func (c *PCPCounterVector) Set(val int64, instance string) error
Set sets the value of a particular instance of PCPCounterVector.
func (*PCPCounterVector) SetAll ¶
func (c *PCPCounterVector) SetAll(val int64)
SetAll sets all instances to the same value and panics on an error.
func (*PCPCounterVector) Up ¶
func (c *PCPCounterVector) Up(instance string)
Up increments the value of a particular instance ny 1.
func (*PCPCounterVector) UpAll ¶
func (c *PCPCounterVector) UpAll()
UpAll ups all instances and panics on an error.
type PCPGauge ¶
type PCPGauge struct {
// contains filtered or unexported fields
}
PCPGauge defines a PCP compatible Gauge metric
func NewPCPGauge ¶
NewPCPGauge creates a new PCPGauge instance. Tt requires an initial float64 value and a metric name for construction. Optionally it can also take a couple of description strings that are used as short and long descriptions respectively. Internally it creates a PCP SingletonMetric with DoubleType, InstantSemantics and CountUnit.
func (PCPGauge) Indom ¶
func (m PCPGauge) Indom() *PCPInstanceDomain
type PCPGaugeVector ¶
type PCPGaugeVector struct {
// contains filtered or unexported fields
}
PCPGaugeVector implements a GaugeVector
func NewPCPGaugeVector ¶
func NewPCPGaugeVector(values map[string]float64, name string, desc ...string) (*PCPGaugeVector, error)
NewPCPGaugeVector creates a new instance of a PCPGaugeVector. It requires a name and map of instance names to their values. Optionally, it can also accept a couple of strings providing more details about the metric.
func (*PCPGaugeVector) Dec ¶
func (g *PCPGaugeVector) Dec(inc float64, instance string) error
Dec decrements the value of a particular instance of PCPGaugeVector
func (*PCPGaugeVector) DecAll ¶
func (g *PCPGaugeVector) DecAll(val float64)
DecAll decrements all instances by the same value and panics on an error
func (*PCPGaugeVector) Inc ¶
func (g *PCPGaugeVector) Inc(inc float64, instance string) error
Inc increments the value of a particular instance of PCPGaugeVector
func (*PCPGaugeVector) IncAll ¶
func (g *PCPGaugeVector) IncAll(val float64)
IncAll increments all instances by the same value and panics on an error
func (PCPGaugeVector) Indom ¶
func (m PCPGaugeVector) Indom() *PCPInstanceDomain
Indom returns the instance domain for the metric.
func (PCPGaugeVector) Instances ¶
func (m PCPGaugeVector) Instances() []string
Instances returns a slice containing all instances in the InstanceMetric. Basically a shorthand for metric.Indom().Instances().
func (*PCPGaugeVector) MustDec ¶
func (g *PCPGaugeVector) MustDec(inc float64, instance string)
MustDec panics if Dec fails
func (*PCPGaugeVector) MustInc ¶
func (g *PCPGaugeVector) MustInc(inc float64, instance string)
MustInc panics if Inc fails
func (*PCPGaugeVector) MustSet ¶
func (g *PCPGaugeVector) MustSet(val float64, instance string)
MustSet panics if Set fails
func (*PCPGaugeVector) Set ¶
func (g *PCPGaugeVector) Set(val float64, instance string) error
Set sets the value of a particular instance of PCPGaugeVector
func (*PCPGaugeVector) SetAll ¶
func (g *PCPGaugeVector) SetAll(val float64)
SetAll sets all instances to the same value and panics on an error
type PCPHistogram ¶
type PCPHistogram struct {
// contains filtered or unexported fields
}
PCPHistogram implements a histogram for PCP backed by the coda hale hdrhistogram https://github.com/codahale/hdrhistogram
func NewPCPHistogram ¶
func NewPCPHistogram(name string, low, high int64, sigfigures int, unit MetricUnit, desc ...string) (*PCPHistogram, error)
NewPCPHistogram returns a new instance of PCPHistogram. The lowest value for `low` is 0. The highest value for `high` is 3,600,000,000. `low` **must** be less than `high`. The value of `sigfigures` can be between 1 and 5. It also requires a unit to be explicitly passed for construction. Optionally, a couple of description strings may be passed as the short and long descriptions of the metric.
func (*PCPHistogram) Buckets ¶
func (h *PCPHistogram) Buckets() []*HistogramBucket
Buckets returns a list of histogram buckets.
func (*PCPHistogram) High ¶
func (h *PCPHistogram) High() int64
High returns the maximum recordable value.
func (PCPHistogram) Indom ¶
func (m PCPHistogram) Indom() *PCPInstanceDomain
Indom returns the instance domain for the metric.
func (PCPHistogram) Instances ¶
func (m PCPHistogram) Instances() []string
Instances returns a slice containing all instances in the InstanceMetric. Basically a shorthand for metric.Indom().Instances().
func (*PCPHistogram) Low ¶
func (h *PCPHistogram) Low() int64
Low returns the minimum recordable value.
func (*PCPHistogram) Max ¶
func (h *PCPHistogram) Max() int64
Max returns the maximum recorded value so far.
func (*PCPHistogram) Mean ¶
func (h *PCPHistogram) Mean() float64
Mean returns the mean of all values recorded so far.
func (*PCPHistogram) Min ¶
func (h *PCPHistogram) Min() int64
Min returns the minimum recorded value so far.
func (*PCPHistogram) MustRecord ¶
func (h *PCPHistogram) MustRecord(val int64)
MustRecord panics if Record fails.
func (*PCPHistogram) MustRecordN ¶
func (h *PCPHistogram) MustRecordN(val, n int64)
MustRecordN panics if RecordN fails.
func (*PCPHistogram) Percentile ¶
func (h *PCPHistogram) Percentile(p float64) int64
Percentile returns the value at the passed percentile.
func (*PCPHistogram) Record ¶
func (h *PCPHistogram) Record(val int64) error
Record records a new value.
func (*PCPHistogram) RecordN ¶
func (h *PCPHistogram) RecordN(val, n int64) error
RecordN records multiple instances of the same value.
func (*PCPHistogram) StandardDeviation ¶
func (h *PCPHistogram) StandardDeviation() float64
StandardDeviation returns the standard deviation of all values recorded so far.
func (*PCPHistogram) Variance ¶
func (h *PCPHistogram) Variance() float64
Variance returns the variance of all values recorded so far.
type PCPInstanceDomain ¶
type PCPInstanceDomain struct {
// contains filtered or unexported fields
}
PCPInstanceDomain wraps a PCP compatible instance domain
func NewPCPInstanceDomain ¶
func NewPCPInstanceDomain(name string, instances []string, desc ...string) (*PCPInstanceDomain, error)
NewPCPInstanceDomain creates a new instance domain or returns an already created one for the passed name NOTE: this is different from parfait's idea of generating ids for InstanceDomains We simply generate a unique 32 bit hash for an instance domain name, and if it has not already been created, we create it, otherwise we return the already created version
func (*PCPInstanceDomain) Description ¶
func (indom *PCPInstanceDomain) Description() string
Description returns the description for PCPInstanceDomain
func (*PCPInstanceDomain) HasInstance ¶
func (indom *PCPInstanceDomain) HasInstance(name string) bool
HasInstance returns true if an instance of the specified name is in the Indom
func (*PCPInstanceDomain) ID ¶
func (indom *PCPInstanceDomain) ID() uint32
ID returns the id for PCPInstanceDomain
func (*PCPInstanceDomain) InstanceCount ¶
func (indom *PCPInstanceDomain) InstanceCount() int
InstanceCount returns the number of instances in the current instance domain
func (*PCPInstanceDomain) Instances ¶
func (indom *PCPInstanceDomain) Instances() []string
Instances returns a slice of defined instances for the instance domain
func (*PCPInstanceDomain) MatchInstances ¶
func (indom *PCPInstanceDomain) MatchInstances(ins []string) bool
MatchInstances returns true if the passed InstanceDomain has exactly the same instances as the passed array
func (*PCPInstanceDomain) Name ¶
func (indom *PCPInstanceDomain) Name() string
Name returns the name for PCPInstanceDomain
func (*PCPInstanceDomain) String ¶
func (indom *PCPInstanceDomain) String() string
type PCPInstanceMetric ¶
type PCPInstanceMetric struct {
// contains filtered or unexported fields
}
PCPInstanceMetric represents a PCPMetric that can have multiple values over multiple instances in an instance domain.
func NewPCPInstanceMetric ¶
func NewPCPInstanceMetric(vals Instances, name string, indom *PCPInstanceDomain, t MetricType, s MetricSemantics, u MetricUnit, desc ...string) (*PCPInstanceMetric, error)
NewPCPInstanceMetric creates a new instance of PCPSingletonMetric. it takes 2 extra optional strings as short and long description parameters, which on not being present are set to empty strings.
func (PCPInstanceMetric) Indom ¶
func (m PCPInstanceMetric) Indom() *PCPInstanceDomain
Indom returns the instance domain for the metric.
func (PCPInstanceMetric) Instances ¶
func (m PCPInstanceMetric) Instances() []string
Instances returns a slice containing all instances in the InstanceMetric. Basically a shorthand for metric.Indom().Instances().
func (*PCPInstanceMetric) MustSetInstance ¶
func (m *PCPInstanceMetric) MustSetInstance(val interface{}, instance string)
MustSetInstance is a SetInstance that panics.
func (*PCPInstanceMetric) SetInstance ¶
func (m *PCPInstanceMetric) SetInstance(val interface{}, instance string) error
SetInstance sets the value for a particular instance of the metric.
func (*PCPInstanceMetric) ValInstance ¶
func (m *PCPInstanceMetric) ValInstance(instance string) (interface{}, error)
ValInstance returns the value for a particular instance of the metric.
type PCPMetric ¶
type PCPMetric interface { Metric // a PCPMetric will always have an instance domain, even if it is nil Indom() *PCPInstanceDomain ShortDescription() string LongDescription() string }
PCPMetric defines the interface for a metric that is compatible with PCP.
type PCPRegistry ¶
type PCPRegistry struct {
// contains filtered or unexported fields
}
PCPRegistry implements a registry for PCP as the client
func NewPCPRegistry ¶
func NewPCPRegistry() *PCPRegistry
NewPCPRegistry creates a new PCPRegistry object
func (*PCPRegistry) AddInstanceDomain ¶
func (r *PCPRegistry) AddInstanceDomain(indom InstanceDomain) error
AddInstanceDomain will add a new instance domain to the current registry
func (*PCPRegistry) AddInstanceDomainByName ¶
func (r *PCPRegistry) AddInstanceDomainByName(name string, instances []string) (InstanceDomain, error)
AddInstanceDomainByName adds an instance domain using passed parameters
func (*PCPRegistry) AddMetric ¶
func (r *PCPRegistry) AddMetric(m Metric) error
AddMetric will add a new metric to the current registry
func (*PCPRegistry) AddMetricByString ¶
func (r *PCPRegistry) AddMetricByString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)
AddMetricByString dynamically creates a PCPMetric
func (*PCPRegistry) HasInstanceDomain ¶
func (r *PCPRegistry) HasInstanceDomain(name string) bool
HasInstanceDomain returns true if the registry already has an indom of the specified name
func (*PCPRegistry) HasMetric ¶
func (r *PCPRegistry) HasMetric(name string) bool
HasMetric returns true if the registry already has a metric of the specified name
func (*PCPRegistry) InstanceCount ¶
func (r *PCPRegistry) InstanceCount() int
InstanceCount returns the number of instances across all indoms in the registry
func (*PCPRegistry) InstanceDomainCount ¶
func (r *PCPRegistry) InstanceDomainCount() int
InstanceDomainCount returns the number of instance domains in the registry
func (*PCPRegistry) MetricCount ¶
func (r *PCPRegistry) MetricCount() int
MetricCount returns the number of metrics in the registry
func (*PCPRegistry) StringCount ¶
func (r *PCPRegistry) StringCount() int
StringCount returns the number of strings in the registry
func (*PCPRegistry) ValuesCount ¶
func (r *PCPRegistry) ValuesCount() int
ValuesCount returns the number of values in the registry
type PCPSingletonMetric ¶
type PCPSingletonMetric struct {
// contains filtered or unexported fields
}
PCPSingletonMetric defines a singleton metric with no instance domain only a value and a valueoffset.
func NewPCPSingletonMetric ¶
func NewPCPSingletonMetric(val interface{}, name string, t MetricType, s MetricSemantics, u MetricUnit, desc ...string) (*PCPSingletonMetric, error)
NewPCPSingletonMetric creates a new instance of PCPSingletonMetric it takes 2 extra optional strings as short and long description parameters, which on not being present are set to blank strings.
func (PCPSingletonMetric) Indom ¶
func (m PCPSingletonMetric) Indom() *PCPInstanceDomain
func (*PCPSingletonMetric) MustSet ¶
func (m *PCPSingletonMetric) MustSet(val interface{})
MustSet is a Set that panics on failure.
func (*PCPSingletonMetric) Set ¶
func (m *PCPSingletonMetric) Set(val interface{}) error
Set Sets the current value of PCPSingletonMetric.
func (*PCPSingletonMetric) String ¶
func (m *PCPSingletonMetric) String() string
func (*PCPSingletonMetric) Val ¶
func (m *PCPSingletonMetric) Val() interface{}
Val returns the current Set value of PCPSingletonMetric.
type PCPTimer ¶
type PCPTimer struct {
// contains filtered or unexported fields
}
PCPTimer implements a PCP compatible Timer It also functionally implements a metric with elapsed type from PCP
func NewPCPTimer ¶
NewPCPTimer creates a new PCPTimer instance of the specified unit. It requires a metric name and a TimeUnit for construction. It can optionally take a couple of description strings. Internally it uses a PCP SingletonMetric.
func (PCPTimer) Indom ¶
func (m PCPTimer) Indom() *PCPInstanceDomain
type Registry ¶
type Registry interface { // checks if an instance domain of the passed name is already present or not HasInstanceDomain(name string) bool // checks if an metric of the passed name is already present or not HasMetric(name string) bool // returns the number of Metrics in the current registry MetricCount() int // returns the number of Values in the current registry ValuesCount() int // returns the number of Instance Domains in the current registry InstanceDomainCount() int // returns the number of instances across all instance domains in the current registry InstanceCount() int // returns the number of non null strings initialized in the current registry StringCount() int // adds a InstanceDomain object to the writer AddInstanceDomain(InstanceDomain) error // adds a InstanceDomain object after constructing it using passed name and instances AddInstanceDomainByName(name string, instances []string) (InstanceDomain, error) // adds a Metric object to the writer AddMetric(Metric) error // adds a Metric object after parsing the passed string for Instances and InstanceDomains AddMetricByString(name string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error) }
Registry defines a valid set of instance domains and metrics
type SingletonMetric ¶
type SingletonMetric interface { Metric // gets the value of the metric Val() interface{} // sets the value of the metric to a value, optionally returns an error on failure Set(interface{}) error // tries to set and panics on error MustSet(interface{}) }
SingletonMetric defines the interface for a metric that stores only one value.
type SpaceUnit ¶
type SpaceUnit uint32
SpaceUnit is an enumerated type representing all units for space.
const ( ByteUnit SpaceUnit = 1<<28 | iota<<16 KilobyteUnit MegabyteUnit GigabyteUnit TerabyteUnit PetabyteUnit ExabyteUnit )
Possible values for SpaceUnit.
func (SpaceUnit) Count ¶
func (s SpaceUnit) Count(c CountUnit, dimension int8) MetricUnit
Count adds a count unit to the current unit at a specific dimension
func (SpaceUnit) PMAPI ¶
PMAPI returns the PMAPI representation for a SpaceUnit for space units bits 0-3 are 1 and bits 13-16 are scale
type TimeUnit ¶
type TimeUnit uint32
TimeUnit is an enumerated type representing all possible units for representing time.
const ( NanosecondUnit TimeUnit = 1<<24 | iota<<12 MicrosecondUnit MillisecondUnit SecondUnit MinuteUnit HourUnit )
Possible Values for TimeUnit. for time units bits 4-7 are 1 and bits 17-20 are scale.
func (TimeUnit) Count ¶
func (t TimeUnit) Count(c CountUnit, dimension int8) MetricUnit
Count adds a count unit to the current unit at a specific dimension
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package bytewriter implements writers that support concurrent writing within a fixed length block
|
Package bytewriter implements writers that support concurrent writing within a fixed length block |
examples
|
|
acme
A golang implementation of the acme factory examples from python and Java APIs
|
A golang implementation of the acme factory examples from python and Java APIs |
download
This is an example of using composite units It makes successive downloads of the linux source code and reports the download speed as well as the download time
|
This is an example of using composite units It makes successive downloads of the linux source code and reports the download speed as well as the download time |
singleton_string
this example showcases speeds metric inference from strings property
|
this example showcases speeds metric inference from strings property |
Package mmvdump implements a go port of the C mmvdump utility included in PCP Core
|
Package mmvdump implements a go port of the C mmvdump utility included in PCP Core |