Documentation ¶
Index ¶
- Constants
- Variables
- func EnableTracing()
- func RemoveAppCounters(eui protocol.EUI)
- func RemoveGatewayCounters(eui protocol.EUI)
- func Stopwatch(counter *histogramCounter, opToMeasure func())
- func TraceHandler() http.HandlerFunc
- type AverageGauge
- type Averages
- type Endpoint
- type Histogram
- type MessageCounter
- type TimeSeries
- type Timer
Constants ¶
const ( Minutes = intervalType(60) Hours = intervalType(24) Days = intervalType(30) )
This is the intervals that can be used for TimeSeries instances
const HistogramSize = 32
HistogramSize is the number of elements in the histogram.
Variables ¶
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 RemoveAppCounters ¶
RemoveAppCounters removes the associated gateway counters
func RemoveGatewayCounters ¶
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 ¶
NewEndpoint returns a new Endpoint instance
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
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 (*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.