metric

package
v0.0.0-...-986d81d Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package metric contains the structs and logic to handle aggregating transmission and reception statistics for quantum.

All of the metrics collected by quantum are represented by monotonically incrementing uint64 counters, and will only reset in the event of an application restart or if the counters increment beyond the size of a uint64.

The currently collected metrics are as follows:

  • Packets
  • Dropped Packets
  • Bytes
  • Dropped Bytes

The metrics are split out based on the queue and the link that handled the transmission, as well as generally over all queues/links. Where a link represents the remote peer involved in the transmission, and a queue represents the internal packet queue.

Index

Constants

View Source
const (
	// Rx metric
	Rx = iota

	// Tx metric
	Tx
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {

	// Metrics is the channel Metric structs are sent to for aggregation and export via the rest api
	Metrics chan *Metric
	// contains filtered or unexported fields
}

Aggregator is a struct for monitoring and aggregating quantum metrics via an embedded channel.

func New

func New(cfg *common.Config) *Aggregator

New generates an Aggregator instance for aggregating statistics data for quantum.

func (*Aggregator) Bytes

func (aggregator *Aggregator) Bytes(pretty bool) []byte

Bytes returns a byte slice json representation of the underlying MetricsLog struct in either flat or prettified notation, if there is an error while marshalling data a nil slice is returned.

func (*Aggregator) Start

func (aggregator *Aggregator) Start()

Start aggregating and serving requests for statistics data.

func (*Aggregator) Stop

func (aggregator *Aggregator) Stop()

Stop aggregating and receiving requests for statistics data.

type Metric

type Metric struct {
	// The remote private ip associated with the packet.
	PrivateIP string

	// The queue handling the packet.
	Queue int

	// The size of the packet in bytes.
	Bytes uint64

	// The type of the packet, either Rx or Tx.
	Type int

	// Whether or not the packet was dropped.
	Dropped bool
}

Metric is used to represent a single incoming or outgoing packet's metric.

type Metrics

type Metrics struct {
	// The number of packets quantum has dropped.
	DroppedPackets uint64 `json:"droppedPackets"`

	// The number of packets successfully handled by quantum.
	Packets uint64 `json:"packets"`

	// The number of bytes quantum has dropped.
	DroppedBytes uint64 `json:"droppedBytes"`

	// The number of bytes successfully handled by quantum.
	Bytes uint64 `json:"bytes"`

	// The stats for individual links that represent the network traffic of this node in relation to remote nodes.
	Links map[string]*Metrics `json:"links,omitempty"`

	// The stats for individual queues within quantm.
	Queues map[int]*Metrics `json:"queues,omitempty"`
}

Metrics struct for storing aggregated incoming or outgoing statistics.

type MetricsLog

type MetricsLog struct {
	// TxMetrics holds the packet and byte counts for packet transmission.
	TxMetrics *Metrics `json:"tx"`

	// RxMetrics holds the packet and byte counts for packet reception.
	RxMetrics *Metrics `json:"rx"`
}

MetricsLog struct which contains the packet and byte statistics information for quantum.

func (*MetricsLog) Bytes

func (metricsLog *MetricsLog) Bytes(pretty bool) []byte

Bytes returns a byte slice json representation of the MetricsLog struct in either flat or prettified notation, if there is an error while marshalling data a nil slice is returned.

Jump to

Keyboard shortcuts

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