graphizer

package module
v0.0.0-...-afa1d4c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2013 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Graphizer

Graphizer is a go library that talks to graphite.

Usage

g := graphizer.newGraphite(graphizer.UDP, "localhost:5555")
g.Send(graphite.Metric{"path.to.metric", 123, time.Now().Unix()})

Metrics have the following structure:

type Metric struct {
  Path      string
  Value     interface{}
  Timestamp int64
}

There are three methods to push data onto graphite, Write israw access to the socket, whereas Send pushes data onto a channel, and then delivers the metrics async. SendStruct will serialize a struct into an array of graphite metrics and send them out over the wire. see:

  • func (g *Graphite) Write(m Metric) error
  • func (g *Graphite) Send(m Metric)

Documentation

Index

Constants

View Source
const (
	TCP = "tcp"
	UDP = "udp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Graphite

type Graphite struct {
	// contains filtered or unexported fields
}

func NewGraphite

func NewGraphite(proto, endpoint string) *Graphite

create a new Graphite struct and connect to the underlying connection. If the connection isn't immediately successful, we timeout, we sleep, and we retry. if we are underbale to connect after 5 attempts, we panic.

func (*Graphite) Close

func (g *Graphite) Close()

close the underlying connection to graphite

func (*Graphite) Send

func (g *Graphite) Send(m Metric)

Send a single metric to graphite

func (*Graphite) SendStruct

func (g *Graphite) SendStruct(obj interface{})

Transform a struct into an array of metrics and send them to graphite/

func (*Graphite) Write

func (g *Graphite) Write(m Metric) error

Write a metric to the underlying conn, and return an error

type Metric

type Metric struct {
	Path      string
	Value     interface{}
	Timestamp int64
}

the data that is being passed to graphite. Path is the graphite path, Value is the metric value. This is an interface, and can be int, float, etc Timestamp should normally be set to time.Now().Unix()

func ParseStruct

func ParseStruct(x interface{}) []Metric

turn a struct into an array of metrics

func (*Metric) String

func (m *Metric) String() string

Serialize a graphite metric

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL