github.com/ghodss/etcd@v0.3.1-0.20140417172404-cc329bfa55cb/metrics/metrics.go (about)

     1  // Package metrics provides both a means of generating metrics and the ability
     2  // to send metric data to a graphite endpoint.
     3  // The usage of this package without providing a graphite_addr when calling
     4  // NewBucket results in NOP metric objects. No data will be collected.
     5  package metrics
     6  
     7  import (
     8  	"io"
     9  
    10  	gometrics "github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics"
    11  )
    12  
    13  type Timer gometrics.Timer
    14  type Gauge gometrics.Gauge
    15  
    16  type Bucket interface {
    17  	// If a timer exists in this Bucket, return it. Otherwise, create
    18  	// a new timer with the given name and store it in this Bucket.
    19  	// The returned object will fulfull the Timer interface.
    20  	Timer(name string) Timer
    21  
    22  	// This acts similarly to Timer, but with objects that fufill the
    23  	// Gauge interface.
    24  	Gauge(name string) Gauge
    25  
    26  	// Write the current state of all Metrics in a human-readable format
    27  	// to the provide io.Writer.
    28  	Dump(io.Writer)
    29  
    30  	// Instruct the Bucket to periodically push all metric data to the
    31  	// provided graphite endpoint.
    32  	Publish(string) error
    33  }
    34  
    35  // Create a new Bucket object that periodically
    36  func NewBucket(name string) Bucket {
    37  	if name == "" {
    38  		return nilBucket{}
    39  	}
    40  
    41  	return newStandardBucket(name)
    42  }