Documentation ¶
Index ¶
Constants ¶
const DefaultMetricsAddr = ":8125"
DefaultMetricsAddr is the default address on which a MetricReceiver will listen
const MaxPacket = 8096
How big to make the receive buffer. This default size is enough for a jumbo ethernet frame and the largest UDP packet possible.
Variables ¶
var ErrInvalidFormat = errors.New("invalid format")
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface {
HandleMetric(m *Metric)
}
Objects implementing the Handler interface can be used to handle metrics for a Server
type HandlerFunc ¶
type HandlerFunc func(*Metric)
The HandlerFunc type is an adapter to allow the use of ordinary functions as metric handlers
func (HandlerFunc) HandleMetric ¶
func (f HandlerFunc) HandleMetric(m *Metric)
HandleMetric calls f(m)
type Metric ¶
type Metric struct { Type MetricType // The type of metric Bucket string // The name of the bucket where the metric belongs Value float64 // The numeric value of the metric }
Metric represents a single data collected datapoint
type MetricType ¶
type MetricType int
MetricType is an enumeration of all the possible types of Metric
const ( COUNTER MetricType = iota TIMER GAUGE GAUGE_DELTA SET )
func (MetricType) String ¶
func (m MetricType) String() string
type Server ¶
type Server struct { Addr string // UDP address on which to listen for metrics Handler Handler // handler to invoke // contains filtered or unexported fields }
Server receives data on its listening port and converts lines in to Metrics. For each Metric it calls r.Handler.HandleMetric()
func (*Server) ListenAndReceive ¶
ListenAndReceive listens on the UDP network address of srv.Addr and then calls Receive to handle the incoming datagrams. If Addr is blank then DefaultMetricsAddr is used.