speed: github.com/performancecopilot/speed Index | Files | Directories

package speed

import "github.com/performancecopilot/speed"

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

Package Files

client.go config.go countunit_string.go instance.go instance_domain.go metrics.go metricsemantics_string.go metrictype_string.go mmvflag_string.go registry.go spaceunit_string.go speed.go timeunit_string.go

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.1"

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

type Client Uses

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 Uses

type CountUnit uint32

CountUnit is a type representing a counted quantity.

const OneUnit CountUnit = 1<<20 | iota<<8

OneUnit represents the only CountUnit. For count units bits 8-11 are 1 and bits 21-24 are scale.

func (CountUnit) Count Uses

func (c CountUnit) Count(CountUnit, int8) MetricUnit

Count adds a count unit to the current unit at a specific dimension

func (CountUnit) PMAPI Uses

func (c CountUnit) PMAPI() uint32

PMAPI returns the PMAPI representation for a CountUnit.

func (CountUnit) Space Uses

func (c CountUnit) Space(s SpaceUnit, dimension int8) MetricUnit

Space adds a space unit to the current unit at a specific dimension

func (CountUnit) String Uses

func (i CountUnit) String() string

func (CountUnit) Time Uses

func (c CountUnit) Time(t TimeUnit, dimension int8) MetricUnit

Time adds a time unit to the current unit at a specific dimension

type Counter Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type HistogramBucket struct {
    From, To, Count int64
}

HistogramBucket is a single histogram bucket within a fixed range.

type InstanceDomain Uses

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 Uses

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 Uses

type Instances map[string]interface{}

Instances defines a valid collection of instance name and values

func (Instances) Keys Uses

func (i Instances) Keys() []string

Keys collects and returns all the keys in all instance values

type MMVFlag Uses

type MMVFlag int

MMVFlag represents an enumerated type to represent mmv flag values

const (
    NoPrefixFlag MMVFlag = 1 << iota
    ProcessFlag
    SentinelFlag
)

values for MMVFlag

func (MMVFlag) String Uses

func (i MMVFlag) String() string

type Metric Uses

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 Uses

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 Uses

func (i MetricSemantics) String() string

type MetricType Uses

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 Uses

func (m MetricType) IsCompatible(val interface{}) bool

IsCompatible checks if the passed value is compatible with the current MetricType.

func (MetricType) String Uses

func (i MetricType) String() string

type MetricUnit Uses

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 Uses

func NewMetricUnit() MetricUnit

NewMetricUnit returns a new object for initialization

type PCPClient Uses

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

PCPClient implements a client that can generate instrumentation for PCP

func NewPCPClient Uses

func NewPCPClient(name string) (*PCPClient, error)

NewPCPClient initializes a new PCPClient object

func NewPCPClientWithRegistry Uses

func NewPCPClientWithRegistry(name string, registry *PCPRegistry) (*PCPClient, error)

NewPCPClientWithRegistry initializes a new PCPClient object with the given registry

func (*PCPClient) Length Uses

func (c *PCPClient) Length() int

Length returns the byte length of data in the mmv file written by the current writer

func (*PCPClient) MustRegister Uses

func (c *PCPClient) MustRegister(m Metric)

MustRegister is simply a Register that can panic

func (*PCPClient) MustRegisterIndom Uses

func (c *PCPClient) MustRegisterIndom(indom InstanceDomain)

MustRegisterIndom is simply a RegisterIndom that can panic

func (*PCPClient) MustRegisterString Uses

func (c *PCPClient) MustRegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) Metric

MustRegisterString is simply a RegisterString that panics

func (*PCPClient) MustStart Uses

func (c *PCPClient) MustStart()

MustStart is a start that panics

func (*PCPClient) MustStop Uses

func (c *PCPClient) MustStop()

MustStop is a stop that panics

func (*PCPClient) Register Uses

func (c *PCPClient) Register(m Metric) error

Register is simply a shorthand for Registry().AddMetric

func (*PCPClient) RegisterIndom Uses

func (c *PCPClient) RegisterIndom(indom InstanceDomain) error

RegisterIndom is simply a shorthand for Registry().AddInstanceDomain

func (*PCPClient) RegisterString Uses

func (c *PCPClient) RegisterString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)

RegisterString is simply a shorthand for Registry().AddMetricByString

func (*PCPClient) Registry Uses

func (c *PCPClient) Registry() Registry

Registry returns a writer's registry

func (*PCPClient) SetFlag Uses

func (c *PCPClient) SetFlag(flag MMVFlag) error

SetFlag sets the MMVflag for the client

func (*PCPClient) Start Uses

func (c *PCPClient) Start() error

Start dumps existing registry data

func (*PCPClient) Stop Uses

func (c *PCPClient) Stop() error

Stop removes existing mapping and cleans up

type PCPCounter Uses

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

PCPCounter implements a PCP compatible Counter Metric.

func NewPCPCounter Uses

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 Uses

func (c *PCPCounter) Inc(val int64) error

Inc increases the stored counter's value by the passed increment.

func (PCPCounter) Indom Uses

func (m PCPCounter) Indom() *PCPInstanceDomain

func (*PCPCounter) MustInc Uses

func (c *PCPCounter) MustInc(val int64)

MustInc is Inc that panics on failure.

func (*PCPCounter) Set Uses

func (c *PCPCounter) Set(val int64) error

Set sets the value of the counter.

func (*PCPCounter) Up Uses

func (c *PCPCounter) Up()

Up increases the counter by 1.

func (*PCPCounter) Val Uses

func (c *PCPCounter) Val() int64

Val returns the current value of the counter.

type PCPCounterVector Uses

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

PCPCounterVector implements a CounterVector

func NewPCPCounterVector Uses

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 Uses

func (c *PCPCounterVector) Inc(inc int64, instance string) error

Inc increments the value of a particular instance of PCPCounterVector.

func (*PCPCounterVector) IncAll Uses

func (c *PCPCounterVector) IncAll(val int64)

IncAll increments all instances by the same value and panics on an error.

func (PCPCounterVector) Indom Uses

func (m PCPCounterVector) Indom() *PCPInstanceDomain

Indom returns the instance domain for the metric.

func (PCPCounterVector) Instances Uses

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 Uses

func (c *PCPCounterVector) MustInc(inc int64, instance string)

MustInc panics if Inc fails.

func (*PCPCounterVector) MustSet Uses

func (c *PCPCounterVector) MustSet(val int64, instance string)

MustSet panics if Set fails.

func (*PCPCounterVector) Set Uses

func (c *PCPCounterVector) Set(val int64, instance string) error

Set sets the value of a particular instance of PCPCounterVector.

func (*PCPCounterVector) SetAll Uses

func (c *PCPCounterVector) SetAll(val int64)

SetAll sets all instances to the same value and panics on an error.

func (*PCPCounterVector) Up Uses

func (c *PCPCounterVector) Up(instance string)

Up increments the value of a particular instance ny 1.

func (*PCPCounterVector) UpAll Uses

func (c *PCPCounterVector) UpAll()

UpAll ups all instances and panics on an error.

func (*PCPCounterVector) Val Uses

func (c *PCPCounterVector) Val(instance string) (int64, error)

Val returns the value of a particular instance of PCPCounterVector.

type PCPGauge Uses

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

PCPGauge defines a PCP compatible Gauge metric

func NewPCPGauge Uses

func NewPCPGauge(val float64, name string, desc ...string) (*PCPGauge, error)

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) Dec Uses

func (g *PCPGauge) Dec(val float64) error

Dec adds a value to the existing Gauge value.

func (*PCPGauge) Inc Uses

func (g *PCPGauge) Inc(val float64) error

Inc adds a value to the existing Gauge value.

func (PCPGauge) Indom Uses

func (m PCPGauge) Indom() *PCPInstanceDomain

func (*PCPGauge) MustDec Uses

func (g *PCPGauge) MustDec(val float64)

MustDec will panic if Dec fails.

func (*PCPGauge) MustInc Uses

func (g *PCPGauge) MustInc(val float64)

MustInc will panic if Inc fails.

func (*PCPGauge) MustSet Uses

func (g *PCPGauge) MustSet(val float64)

MustSet will panic if Set fails.

func (*PCPGauge) Set Uses

func (g *PCPGauge) Set(val float64) error

Set sets the current value of the Gauge.

func (*PCPGauge) Val Uses

func (g *PCPGauge) Val() float64

Val returns the current value of the Gauge.

type PCPGaugeVector Uses

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

PCPGaugeVector implements a GaugeVector

func NewPCPGaugeVector Uses

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 Uses

func (g *PCPGaugeVector) Dec(inc float64, instance string) error

Dec decrements the value of a particular instance of PCPGaugeVector

func (*PCPGaugeVector) DecAll Uses

func (g *PCPGaugeVector) DecAll(val float64)

DecAll decrements all instances by the same value and panics on an error

func (*PCPGaugeVector) Inc Uses

func (g *PCPGaugeVector) Inc(inc float64, instance string) error

Inc increments the value of a particular instance of PCPGaugeVector

func (*PCPGaugeVector) IncAll Uses

func (g *PCPGaugeVector) IncAll(val float64)

IncAll increments all instances by the same value and panics on an error

func (PCPGaugeVector) Indom Uses

func (m PCPGaugeVector) Indom() *PCPInstanceDomain

Indom returns the instance domain for the metric.

func (PCPGaugeVector) Instances Uses

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 Uses

func (g *PCPGaugeVector) MustDec(inc float64, instance string)

MustDec panics if Dec fails

func (*PCPGaugeVector) MustInc Uses

func (g *PCPGaugeVector) MustInc(inc float64, instance string)

MustInc panics if Inc fails

func (*PCPGaugeVector) MustSet Uses

func (g *PCPGaugeVector) MustSet(val float64, instance string)

MustSet panics if Set fails

func (*PCPGaugeVector) Set Uses

func (g *PCPGaugeVector) Set(val float64, instance string) error

Set sets the value of a particular instance of PCPGaugeVector

func (*PCPGaugeVector) SetAll Uses

func (g *PCPGaugeVector) SetAll(val float64)

SetAll sets all instances to the same value and panics on an error

func (*PCPGaugeVector) Val Uses

func (g *PCPGaugeVector) Val(instance string) (float64, error)

Val returns the value of a particular instance of PCPGaugeVector

type PCPHistogram Uses

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 Uses

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 Uses

func (h *PCPHistogram) Buckets() []*HistogramBucket

Buckets returns a list of histogram buckets.

func (*PCPHistogram) High Uses

func (h *PCPHistogram) High() int64

High returns the maximum recordable value.

func (PCPHistogram) Indom Uses

func (m PCPHistogram) Indom() *PCPInstanceDomain

Indom returns the instance domain for the metric.

func (PCPHistogram) Instances Uses

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 Uses

func (h *PCPHistogram) Low() int64

Low returns the minimum recordable value.

func (*PCPHistogram) Max Uses

func (h *PCPHistogram) Max() int64

Max returns the maximum recorded value so far.

func (*PCPHistogram) Mean Uses

func (h *PCPHistogram) Mean() float64

Mean returns the mean of all values recorded so far.

func (*PCPHistogram) Min Uses

func (h *PCPHistogram) Min() int64

Min returns the minimum recorded value so far.

func (*PCPHistogram) MustRecord Uses

func (h *PCPHistogram) MustRecord(val int64)

MustRecord panics if Record fails.

func (*PCPHistogram) MustRecordN Uses

func (h *PCPHistogram) MustRecordN(val, n int64)

MustRecordN panics if RecordN fails.

func (*PCPHistogram) Percentile Uses

func (h *PCPHistogram) Percentile(p float64) int64

Percentile returns the value at the passed percentile.

func (*PCPHistogram) Record Uses

func (h *PCPHistogram) Record(val int64) error

Record records a new value.

func (*PCPHistogram) RecordN Uses

func (h *PCPHistogram) RecordN(val, n int64) error

RecordN records multiple instances of the same value.

func (*PCPHistogram) StandardDeviation Uses

func (h *PCPHistogram) StandardDeviation() float64

StandardDeviation returns the standard deviation of all values recorded so far.

func (*PCPHistogram) Variance Uses

func (h *PCPHistogram) Variance() float64

Variance returns the variance of all values recorded so far.

type PCPInstanceDomain Uses

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

PCPInstanceDomain wraps a PCP compatible instance domain

func NewPCPInstanceDomain Uses

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 Uses

func (indom *PCPInstanceDomain) Description() string

Description returns the description for PCPInstanceDomain

func (*PCPInstanceDomain) HasInstance Uses

func (indom *PCPInstanceDomain) HasInstance(name string) bool

HasInstance returns true if an instance of the specified name is in the Indom

func (*PCPInstanceDomain) ID Uses

func (indom *PCPInstanceDomain) ID() uint32

ID returns the id for PCPInstanceDomain

func (*PCPInstanceDomain) InstanceCount Uses

func (indom *PCPInstanceDomain) InstanceCount() int

InstanceCount returns the number of instances in the current instance domain

func (*PCPInstanceDomain) Instances Uses

func (indom *PCPInstanceDomain) Instances() []string

Instances returns a slice of defined instances for the instance domain

func (*PCPInstanceDomain) MatchInstances Uses

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 Uses

func (indom *PCPInstanceDomain) Name() string

Name returns the name for PCPInstanceDomain

func (*PCPInstanceDomain) String Uses

func (indom *PCPInstanceDomain) String() string

type PCPInstanceMetric Uses

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 Uses

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 Uses

func (m PCPInstanceMetric) Indom() *PCPInstanceDomain

Indom returns the instance domain for the metric.

func (PCPInstanceMetric) Instances Uses

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 Uses

func (m *PCPInstanceMetric) MustSetInstance(val interface{}, instance string)

MustSetInstance is a SetInstance that panics.

func (*PCPInstanceMetric) SetInstance Uses

func (m *PCPInstanceMetric) SetInstance(val interface{}, instance string) error

SetInstance sets the value for a particular instance of the metric.

func (*PCPInstanceMetric) ValInstance Uses

func (m *PCPInstanceMetric) ValInstance(instance string) (interface{}, error)

ValInstance returns the value for a particular instance of the metric.

type PCPMetric Uses

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 Uses

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

PCPRegistry implements a registry for PCP as the client

func NewPCPRegistry Uses

func NewPCPRegistry() *PCPRegistry

NewPCPRegistry creates a new PCPRegistry object

func (*PCPRegistry) AddInstanceDomain Uses

func (r *PCPRegistry) AddInstanceDomain(indom InstanceDomain) error

AddInstanceDomain will add a new instance domain to the current registry

func (*PCPRegistry) AddInstanceDomainByName Uses

func (r *PCPRegistry) AddInstanceDomainByName(name string, instances []string) (InstanceDomain, error)

AddInstanceDomainByName adds an instance domain using passed parameters

func (*PCPRegistry) AddMetric Uses

func (r *PCPRegistry) AddMetric(m Metric) error

AddMetric will add a new metric to the current registry

func (*PCPRegistry) AddMetricByString Uses

func (r *PCPRegistry) AddMetricByString(str string, val interface{}, t MetricType, s MetricSemantics, u MetricUnit) (Metric, error)

AddMetricByString dynamically creates a PCPMetric

func (*PCPRegistry) HasInstanceDomain Uses

func (r *PCPRegistry) HasInstanceDomain(name string) bool

HasInstanceDomain returns true if the registry already has an indom of the specified name

func (*PCPRegistry) HasMetric Uses

func (r *PCPRegistry) HasMetric(name string) bool

HasMetric returns true if the registry already has a metric of the specified name

func (*PCPRegistry) InstanceCount Uses

func (r *PCPRegistry) InstanceCount() int

InstanceCount returns the number of instances across all indoms in the registry

func (*PCPRegistry) InstanceDomainCount Uses

func (r *PCPRegistry) InstanceDomainCount() int

InstanceDomainCount returns the number of instance domains in the registry

func (*PCPRegistry) MetricCount Uses

func (r *PCPRegistry) MetricCount() int

MetricCount returns the number of metrics in the registry

func (*PCPRegistry) StringCount Uses

func (r *PCPRegistry) StringCount() int

StringCount returns the number of strings in the registry

func (*PCPRegistry) ValuesCount Uses

func (r *PCPRegistry) ValuesCount() int

ValuesCount returns the number of values in the registry

type PCPSingletonMetric Uses

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 Uses

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 Uses

func (m PCPSingletonMetric) Indom() *PCPInstanceDomain

func (*PCPSingletonMetric) MustSet Uses

func (m *PCPSingletonMetric) MustSet(val interface{})

MustSet is a Set that panics on failure.

func (*PCPSingletonMetric) Set Uses

func (m *PCPSingletonMetric) Set(val interface{}) error

Set Sets the current value of PCPSingletonMetric.

func (*PCPSingletonMetric) String Uses

func (m *PCPSingletonMetric) String() string

func (*PCPSingletonMetric) Val Uses

func (m *PCPSingletonMetric) Val() interface{}

Val returns the current Set value of PCPSingletonMetric.

type PCPTimer Uses

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 Uses

func NewPCPTimer(name string, unit TimeUnit, desc ...string) (*PCPTimer, error)

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 Uses

func (m PCPTimer) Indom() *PCPInstanceDomain

func (*PCPTimer) Reset Uses

func (t *PCPTimer) Reset() error

Reset resets the timer to 0

func (*PCPTimer) Start Uses

func (t *PCPTimer) Start() error

Start signals the timer to start monitoring.

func (*PCPTimer) Stop Uses

func (t *PCPTimer) Stop() (float64, error)

Stop signals the timer to end monitoring and return elapsed time so far.

type Registry Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (s SpaceUnit) PMAPI() uint32

PMAPI returns the PMAPI representation for a SpaceUnit for space units bits 0-3 are 1 and bits 13-16 are scale

func (SpaceUnit) Space Uses

func (s SpaceUnit) Space(SpaceUnit, int8) MetricUnit

Space adds a space unit to the current unit at a specific dimension

func (SpaceUnit) String Uses

func (i SpaceUnit) String() string

func (SpaceUnit) Time Uses

func (s SpaceUnit) Time(t TimeUnit, dimension int8) MetricUnit

Time adds a time unit to the current unit at a specific dimension

type TimeUnit Uses

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 Uses

func (t TimeUnit) Count(c CountUnit, dimension int8) MetricUnit

Count adds a count unit to the current unit at a specific dimension

func (TimeUnit) PMAPI Uses

func (t TimeUnit) PMAPI() uint32

PMAPI returns the PMAPI representation for a TimeUnit.

func (TimeUnit) Space Uses

func (t TimeUnit) Space(s SpaceUnit, dimension int8) MetricUnit

Space adds a space unit to the current unit at a specific dimension

func (TimeUnit) String Uses

func (i TimeUnit) String() string

func (TimeUnit) Time Uses

func (t TimeUnit) Time(TimeUnit, int8) MetricUnit

Time adds a time unit to the current unit at a specific dimension

type Timer Uses

type Timer interface {
    Metric

    Start() error
    Stop() (float64, error)
}

Timer defines a metric that accumulates time periods Start signals the beginning of monitoring. End signals the end of monitoring and adding the elapsed time to the accumulated time, and returning it.

Directories

PathSynopsis
bytewriterPackage bytewriter implements writers that support concurrent writing within a fixed length block
examples/acmeA golang implementation of the acme factory examples from python and Java APIs
examples/basic_histogram
examples/downloadThis 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
examples/http_counter
examples/instance_string
examples/runtime
examples/simple
examples/simple_string_metric
examples/singleton_counter
examples/singleton_stringthis example showcases speeds metric inference from strings property
mmvdumpPackage mmvdump implements a go port of the C mmvdump utility included in PCP Core

Package speed imports 14 packages (graph) and is imported by 56 packages. Updated 2019-05-01. Refresh now. Tools for package owners.