monitoring

package
v0.0.0-...-cfba5c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 19 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Minutes = intervalType(60)
	Hours   = intervalType(24)
	Days    = intervalType(30)
)

This is the intervals that can be used for TimeSeries instances

View Source
const HistogramSize = 32

HistogramSize is the number of elements in the histogram.

Variables

View Source
var (
	GatewayCreated      *timeseriesCounter
	GatewayUpdated      *timeseriesCounter
	GatewayRemoved      *timeseriesCounter
	ApplicationCreated  *timeseriesCounter
	ApplicationUpdated  *timeseriesCounter
	ApplicationRemoved  *timeseriesCounter
	DeviceCreated       *timeseriesCounter
	DeviceUpdated       *timeseriesCounter
	DeviceRemoved       *timeseriesCounter
	LoRaMICFailed       *timeseriesCounter
	LoRaConfirmedUp     *timeseriesCounter // Received by server
	LoRaConfirmedDown   *timeseriesCounter // Received by server
	LoRaUnconfirmedUp   *timeseriesCounter // Sent by server
	LoRaUnconfirmedDown *timeseriesCounter // Sent by server
	LoRaJoinRequest     *timeseriesCounter // Received by server
	LoRaJoinAccept      *timeseriesCounter // Sent by server
	LoRaCounterFailed   *timeseriesCounter // Rejected frame counter
	GatewayIn           *timeseriesCounter
	GatewayOut          *timeseriesCounter
	Decoder             *timeseriesCounter
	Decrypter           *timeseriesCounter
	MACProcessor        *timeseriesCounter
	SchedulerIn         *timeseriesCounter
	SchedulerOut        *timeseriesCounter
	Encoder             *timeseriesCounter

	GatewayChannelOut      *histogramCounter // Time to send message to decoder
	DecoderChannelOut      *histogramCounter // Time to send message to decrypter
	DecrypterChannelOut    *histogramCounter // Time to send message to MAC processor
	MACProcessorChannelOut *histogramCounter // Time to send message to scheduler
	SchedulerChannelOut    *histogramCounter // Time to send message to encoder
	EncoderChannelOut      *histogramCounter // Time to send message to gwid

	TimeGatewaySend      *histogramCounter
	TimeGatewayReceive   *histogramCounter
	TimeDecoder          *histogramCounter
	TimeDecrypter        *histogramCounter
	TimeEncoder          *histogramCounter
	TimeMACProcessor     *histogramCounter
	TimeSchedulerSend    *histogramCounter
	TimeSchedulerProcess *histogramCounter

	TimeIncoming *histogramCounter
	TimeOutgoing *histogramCounter

	MissedDeadline *timeseriesCounter
)

These are the types of counters available. List is WIP

Functions

func EnableTracing

func EnableTracing()

EnableTracing starts the tracing goroutine

func RemoveAppCounters

func RemoveAppCounters(eui protocol.EUI)

RemoveAppCounters removes the associated gateway counters

func RemoveGatewayCounters

func RemoveGatewayCounters(eui protocol.EUI)

RemoveGatewayCounters removes the associated gateway counters

func Stopwatch

func Stopwatch(counter *histogramCounter, opToMeasure func())

Stopwatch times an operation and updates the specified counter with the time taken. Time is logged in microseconds

func TraceHandler

func TraceHandler() http.HandlerFunc

TraceHandler is a simple http.HandleFunc that handles POST requests. A new trace is started with there's a POST request and the trace channel isn't blocking. If the trace channel is blocking 409 conflict will be returned. All other methods returns 405 method not allowed.

Types

type AverageGauge

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

AverageGauge is a gauge with min/max/average for a fixed set of samples

func NewAverageGauge

func NewAverageGauge(count int) *AverageGauge

NewAverageGauge creates a new AgerageGauge instance with the given set of samples.

func (*AverageGauge) Add

func (a *AverageGauge) Add(value float64)

Add adds a new value to the gauge

func (*AverageGauge) Calculate

func (a *AverageGauge) Calculate() Averages

Calculate average, min and max for the current set of samples

func (*AverageGauge) String

func (a *AverageGauge) String() string

String returns the values averaged and encoded as JSON

type Averages

type Averages struct {
	Average float64 `json:"average"`
	Count   int     `json:"count"`
	Min     float64 `json:"min"`
	Max     float64 `json:"max"`
}

Averages is the calculated averages

type Endpoint

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

Endpoint is a type that can launch a http monitoring endpoint.

func NewEndpoint

func NewEndpoint(loopbackOnly bool, port int, profiling bool, tracing bool) (*Endpoint, error)

NewEndpoint returns a new Endpoint instance

func (*Endpoint) Port

func (m *Endpoint) Port() int

Port returns the port the server is running on

func (*Endpoint) ServeHTTP

func (m *Endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Endpoint) Shutdown

func (m *Endpoint) Shutdown() error

Shutdown stops the server. There is a 2 second timeout.

func (*Endpoint) Start

func (m *Endpoint) Start() error

Start launches the server. If the port is set to 0 it will pick a random port to run on.

type Histogram

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

Histogram is a simple histogram with fixed intervals. The intervals are exponents of 2, ie 1, 2, 4, 8... up to 2^32

func NewHistogram

func NewHistogram() *Histogram

NewHistogram creates a new Histogram instance

func (*Histogram) Add

func (h *Histogram) Add(v float64)

Add adds a new item to the histogram.

func (*Histogram) String

func (h *Histogram) String() string

String returns a JSON representation of the histogram. The first index is the count of values <= 1, the next values <= 2 and so on.

func (*Histogram) Values

func (h *Histogram) Values() []int

Values return a copy of the current logged values. The first element will be the values that are <= 1, the next element values that are <= 2

type MessageCounter

type MessageCounter struct {
	MessagesIn  *TimeSeries `json:"messagesIn"`
	MessagesOut *TimeSeries `json:"messagesOut"`
}

MessageCounter holds the counters for a single gateway or application

func GetAppCounters

func GetAppCounters(eui protocol.EUI) *MessageCounter

GetAppCounters returns the gateway counters for the specified EUI. If the counters doesn't exist, a new set of counters will be created.

func GetGatewayCounters

func GetGatewayCounters(eui protocol.EUI) *MessageCounter

GetGatewayCounters returns the gateway counters for the specified EUI. If the counters doesn't exist, a new set of counters will be created.

func NewMessageCounter

func NewMessageCounter(eui protocol.EUI) *MessageCounter

NewMessageCounter creates a new GatewayCounter instance

type TimeSeries

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

TimeSeries represents a time series of values, grouped by a fixed interval (minute, hour, day). Use the Increment() value to increase the counter and GetCounters() to get an array of the recorded values. As a side effect the output will be a rate of events per time interval -- ie if you keep track of new items and call Increment() every time a new item is created you'll get the rate of new elements per time interval out from GetCounters()

func NewTimeSeries

func NewTimeSeries(interval intervalType) *TimeSeries

NewTimeSeries creates a new time series. The identifier

func (*TimeSeries) GetCounts

func (t *TimeSeries) GetCounts() []uint32

GetCounts returns the counts for each time unit. The oldest item it at index 0, the newest item at the end of the array

func (*TimeSeries) Increment

func (t *TimeSeries) Increment()

Increment the current minute, hour, day and month counters

func (*TimeSeries) MarshalJSON

func (t *TimeSeries) MarshalJSON() ([]byte, error)

MarshalJSON dumps the time series as an array

func (*TimeSeries) String

func (t *TimeSeries) String() string

Convert into a JSON string. This satisifies the expvar.Var interface and makes it possible to expose the variable.

type Timer

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

Timer is responsible for timings throughout the pipeline. Timing starts when Begin() is called and is completed when End() is called.

func NewTimer

func NewTimer() Timer

NewTimer creates a new timer

func (*Timer) Begin

func (t *Timer) Begin(section *histogramCounter)

Begin starts timing for a new section. The provided counter is updated with the elapsed time when there's a call to End. Begin and End should be called after one another. If begin is called more than once an error will be logged.

func (*Timer) End

func (t *Timer) End()

End stops timing for a section. Begin must be called before End is called. If there's no timing running at the moment it will log an error and return. The elapsed time from Begin to End will be logged in the counter provided to the Begin call. Time is logged in microseconds.

Jump to

Keyboard shortcuts

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