Documentation
¶
Overview ¶
Package monitor package handle the logging, collection and computation of statistical data. Every application can send some Measure (for the moment, we mostly measure the CPU time but it can be applied later for any kind of measures). The Monitor receives them and updates a Stats struct. This Stats struct can hold many different kinds of Measurements (the measure of a specific action such as "round time" or "verify time" etc). These measurements contain Values which compute the actual min/max/dev/avg values.
The Proxy allows to relay Measure from clients to the listening Monitor. A starter feature is also the DataFilter which can apply some filtering rules to the data before making any statistics about them.
Index ¶
- Constants
- func ConnectSink(addr string) error
- func EndAndCleanup()
- func RecordSingleMeasure(name string, value float64)
- type Counter
- type CounterMeasure
- type DataFilter
- type Measure
- type Monitor
- type PercentileFilter
- type Stats
- func (s *Stats) Collect()
- func (s *Stats) Received() int
- func (s *Stats) String() string
- func (s *Stats) Update(m *singleMeasure)
- func (s *Stats) Value(name string) *Value
- func (s *Stats) WriteHeader(w io.Writer)
- func (s *Stats) WriteIndividualStats(w io.Writer) error
- func (s *Stats) WriteValues(w io.Writer)
- type TimeMeasure
- type Value
- func (t *Value) Avg() float64
- func (t *Value) Collect()
- func (t *Value) Dev() float64
- func (t *Value) Filter(filt DataFilter)
- func (t *Value) HeaderFields() []string
- func (t *Value) Max() float64
- func (t *Value) Min() float64
- func (t *Value) NumValue() int
- func (t *Value) SingleValues(i int) []string
- func (t *Value) Store(newTime float64)
- func (t *Value) String() string
- func (t *Value) Sum() float64
- func (t *Value) Values() []string
Constants ¶
const DefaultSinkPort = 10000
DefaultSinkPort is the default port where a monitor will listen and a proxy will contact the monitor.
const Sink = "0.0.0.0"
Sink is the address where to listen for the monitor. The endpoint can be a monitor.Proxy or a direct connection with measure.go
Variables ¶
This section is empty.
Functions ¶
func ConnectSink ¶
ConnectSink connects to the given endpoint and initialises a json encoder. It can be the address of a proxy or a monitoring process. Returns an error if it could not connect to the endpoint.
func EndAndCleanup ¶
func EndAndCleanup()
EndAndCleanup sends a message to end the logging and closes the connection
func RecordSingleMeasure ¶
RecordSingleMeasure sends the pair name - value to the monitor directly.
Types ¶
type Counter ¶
Counter is an interface that can be used to report multiple values that keeps evolving. The keys in the returned map is the name of the value to record.
type CounterMeasure ¶
type CounterMeasure struct {
// contains filtered or unexported fields
}
CounterMeasure is a struct that takes a Counter and can send the measurements to the monitor. Each time Record() is called, the measurements are put back to 0 (while the Counter still sends increased bytes number).
func NewCounterMeasure ¶
func NewCounterMeasure(name string, counter Counter) *CounterMeasure
NewCounterMeasure returns an CounterMeasure fresh. The base value are set to the values returned by counter.Values().
func (*CounterMeasure) Record ¶
func (cm *CounterMeasure) Record()
Record send the actual number of bytes read and written (**name**_written & **name**_read) and reset the counters.
type DataFilter ¶
DataFilter is a generic interface that can filter data according to some rules. For example, filter out everything outside the 90-th percentile.
type Measure ¶
type Measure interface { // Record must be called when you want to send the value // over the monitor listening. // Implementation of this interface must RESET the value to `0` at the end // of Record(). `0` means the initial value / meaning this measure had when // created. // Example: TimeMeasure.Record() will reset the time to `time.Now()` // CounterMeasure.Record() will reset the counter of the bytes // read / written to 0. // etc Record() }
Measure is an interface for measurements Usage:
measure := monitor.SingleMeasure("bandwidth")
or
measure := monitor.NewTimeMeasure("round") measure.Record()
type Monitor ¶
Monitor struct is used to collect measures and make the statistics about them. It takes a stats object so it update that in a concurrent-safe manner for each new measure it receives.
func NewDefaultMonitor ¶
NewDefaultMonitor returns a new monitor given the stats
func NewMonitor ¶
NewMonitor returns a monitor listening on the given port
type PercentileFilter ¶
type PercentileFilter struct {
// contains filtered or unexported fields
}
PercentileFilter is used to process data before making any statistics about them
func NewPercentileFilter ¶
func NewPercentileFilter(toFilter map[string]float64) PercentileFilter
NewPercentileFilter returns a percentile filter that will filter all values belonging to keys given in the map, by the specified amount of the percentile.
type Stats ¶
Stats holds the different measurements done
func AverageStats ¶
AverageStats will make an average of the given stats
func NewStats ¶
func NewStats(defs map[string]string, df DataFilter) *Stats
NewStats return a Stats with the given defaults values. For example: { "nodes": "10", "simul": "funny_one" }. If df is nil, no filter is taken.
func (*Stats) Collect ¶
func (s *Stats) Collect()
Collect make the final computations before stringing or writing. Automatically done in other methods anyway.
func (*Stats) Update ¶
func (s *Stats) Update(m *singleMeasure)
Update will update the Stats with this given measure
func (*Stats) WriteHeader ¶
WriteHeader will write the header to the writer
func (*Stats) WriteIndividualStats ¶
WriteIndividualStats will write the values to the specified writer but without making averages. Each value should either be:
- represented once - then it'll be copied to all runs
- have the same frequency as the other non-once values
func (*Stats) WriteValues ¶
WriteValues will write the values to the specified writer
type TimeMeasure ¶
type TimeMeasure struct { Wall *singleMeasure CPU *singleMeasure User *singleMeasure // contains filtered or unexported fields }
TimeMeasure represents a measure regarding time: It includes the wallclock time, the cpu time + the user time.
func NewTimeMeasure ¶
func NewTimeMeasure(name string) *TimeMeasure
NewTimeMeasure return *TimeMeasure
func (*TimeMeasure) Record ¶
func (tm *TimeMeasure) Record()
Record sends the measurements to the monitor:
- wall time: *name*_wall
- system time: *name*_system
- user time: *name*_user
type Value ¶
Value is used to compute the statistics it represent the time to an action (setup, shamir round, coll round etc) use it to compute streaming mean + dev
func AverageValue ¶
AverageValue will create a Value averaging all Values given
func (*Value) Collect ¶
func (t *Value) Collect()
Collect will collect all float64 stored in the store's Value and will compute the basic statistics about them such as min, max, dev and avg.
func (*Value) HeaderFields ¶
HeaderFields returns the first line of the CSV-file
func (*Value) SingleValues ¶
SingleValues returns the string representation of an entry in the value
func (*Value) Store ¶
Store takes this new time and stores it for later analysis Since we might want to do percentile sorting, we need to have all the Values For the moment, we do a simple store of the Value, but note that some streaming percentile algorithm exists in case the number of messages is growing to big.