Documentation ¶
Overview ¶
Package graphigo provides a simple go client for the graphite monitoring tool. See http://graphite.readthedocs.org/en/latest/overview.html
Index ¶
- Constants
- type Graphigo
- func (g *Graphigo) Connect() (err error)
- func (g *Graphigo) Disconnect() error
- func (g *Graphigo) InjectConnection(connection io.WriteCloser)
- func (g *Graphigo) Send(metric Metric) error
- func (g *Graphigo) SendAll(metrics []Metric) (err error)
- func (g *Graphigo) SendValue(name string, value interface{}) error
- type GraphiteClient
- type Metric
- type NullClient
Constants ¶
const ( // DefaultTimeout is the timeout that is applied when connecting to a graphite server // if no explicit timeout has been configured. DefaultTimeout = 5 // TimeoutDisabled is used to disable the client timeout entirely TimeoutDisabled = -1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graphigo ¶
type Graphigo struct { Address string Timeout time.Duration Prefix string // contains filtered or unexported fields }
Graphigo is a simple implementation of the GraphiteClient interface You can get new instances using graphigo.NewClient(address)
If you want to configure a global name prefix for all recorded values you can access the globally available Prefix field.
To set a timeout on the underlying connection to graphite, set the Timeout field of this struct.
func NewClient ¶
NewClient creates a new instance of a graphite client. Use the address:port notation to specify the port.
func (*Graphigo) Connect ¶
Connect attempts to establish the connection to the graphite server. This will return an error if a TCP connection can not or has already been established.
func (*Graphigo) Disconnect ¶
Disconnect closes the underlying connection to graphite.
func (*Graphigo) InjectConnection ¶
func (g *Graphigo) InjectConnection(connection io.WriteCloser)
InjectConnection can be used to inject your own implementation of the connection to graphite. The connection is reset by any call to Disconnect().
func (*Graphigo) Send ¶
Send sends a graphigo.Metric to graphite. This can be used to send a metric which has been recorded earlier.
Use SendValue if you want to create and send a metric in one step. Use SendAll if you want to send multiple metrics at once. This will return an error if the client has not yet been connected or the metric name is empty.
func (*Graphigo) SendAll ¶
SendAll sends multiple graphigo.Metric to graphite. This can be used to send multiple metrics that have been recorded earlier.
Use Send if you want to send a single metric. This will return an error if the client has not yet been connected or if any of the metrics has an empty name.
type GraphiteClient ¶
type GraphiteClient interface { Connect() error Disconnect() error SendValue(name string, value interface{}) error Send(Metric) error SendAll([]Metric) error }
GraphiteClient is the interface for a graphigo graphite client. Use it for dependency injection and the good of humanity
type Metric ¶
Metric holds all information that is send to graphite. The value can be any go type but in practice graphite will probably only accept numeric values.
func (Metric) UnixTimestamp ¶
UnixTimestamp returns the the number of seconds elapsed since January 1, 1970 UTC.
type NullClient ¶
type NullClient struct{}
NullClient implements the GraphiteClient but does not perform any actions
func NewNullClient ¶
func NewNullClient() *NullClient
func (*NullClient) Connect ¶
func (c *NullClient) Connect() error
func (*NullClient) Disconnect ¶
func (c *NullClient) Disconnect() error
func (*NullClient) Send ¶
func (c *NullClient) Send(Metric) error
func (*NullClient) SendAll ¶
func (c *NullClient) SendAll([]Metric) error
func (*NullClient) SendValue ¶
func (c *NullClient) SendValue(_ string, _ interface{}) error