Commit 69e8200c authored by Kamil Kisiel's avatar Kamil Kisiel

Added package and metric object docs

parent c94b38cb
/*
Package statsd implements functionality for creating servers compatible with the statsd protocol.
See https://github.com/b/statsd_spec for a description of the protocol.
The main components of the library are MetricReceiver and MetricAggregator,
which are responsible for receiving and aggregating the metrics respectively.
MetricAggregator receives Metric objects via its MetricChan and then aggregates
them based on their type. At every FlushInterval the metrics are flushed via
the aggregator's associated MetricSender object.
Currently the library implements just one type MetricSender, compatible with Graphite
(http://graphite.wikidot.org), but any object implementing the MetricSender
interface can be used with the library.
*/
package statsd
...@@ -5,9 +5,9 @@ import ( ...@@ -5,9 +5,9 @@ import (
"fmt" "fmt"
) )
// MetricType is an enumeration of all the possible types of Metric
type MetricType float64 type MetricType float64
// Enumeration, see http://golang.org/doc/effective_go.html#constants
const ( const (
_ = iota _ = iota
ERROR MetricType = 1 << (10 * iota) ERROR MetricType = 1 << (10 * iota)
...@@ -28,16 +28,19 @@ func (m MetricType) String() string { ...@@ -28,16 +28,19 @@ func (m MetricType) String() string {
return "unknown" return "unknown"
} }
// Metric represents a single data collected datapoint
type Metric struct { type Metric struct {
Type MetricType Type MetricType // The type of metric
Bucket string Bucket string // The name of the bucket where the metric belongs
Value float64 Value float64 // The numeric value of the metric
} }
func (m Metric) String() string { func (m Metric) String() string {
return fmt.Sprintf("{%s, %s, %f}", m.Type, m.Bucket, m.Value) return fmt.Sprintf("{%s, %s, %f}", m.Type, m.Bucket, m.Value)
} }
// MetricMap is used for storing aggregated Metric values.
// The keys of the map are metric bucket names.
type MetricMap map[string]float64 type MetricMap map[string]float64
func (m MetricMap) String() string { func (m MetricMap) String() string {
...@@ -48,6 +51,8 @@ func (m MetricMap) String() string { ...@@ -48,6 +51,8 @@ func (m MetricMap) String() string {
return buf.String() return buf.String()
} }
// MetricListMap is simlar to MetricMap but instead of storing a single aggregated
// Metric value it stores a list of all collected values.
type MetricListMap map[string][]float64 type MetricListMap map[string][]float64
func (m MetricListMap) String() string { func (m MetricListMap) String() string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment