Skip to content
Snippets Groups Projects
Commit 69e8200c authored by Kamil Kisiel's avatar Kamil Kisiel
Browse files

Added package and metric object docs

parent c94b38cb
No related branches found
No related tags found
No related merge requests found
/*
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 (
"fmt"
)
// MetricType is an enumeration of all the possible types of Metric
type MetricType float64
// Enumeration, see http://golang.org/doc/effective_go.html#constants
const (
_ = iota
ERROR MetricType = 1 << (10 * iota)
......@@ -28,16 +28,19 @@ func (m MetricType) String() string {
return "unknown"
}
// Metric represents a single data collected datapoint
type Metric struct {
Type MetricType
Bucket string
Value float64
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
}
func (m Metric) String() string {
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
func (m MetricMap) String() string {
......@@ -48,6 +51,8 @@ func (m MetricMap) String() 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
func (m MetricListMap) String() string {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment