metrics

package
v0.0.0-...-b1c7972 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorGraphiteClientNotConnected = errors.New("graphite client not connected")

Functions

This section is empty.

Types

type GraphiteClient

type GraphiteClient struct {
	Host       string
	Port       int
	Protocol   string
	Timeout    time.Duration
	Prefix     string
	DisableLog bool
	// contains filtered or unexported fields
}

GraphiteClient is a struct that defines the relevant properties of a graphite connection

func NewGraphite

func NewGraphite(host string, port int) (*GraphiteClient, error)

NewGraphite is a factory method that's used to create a new GraphiteClient

func NewGraphiteClient

func NewGraphiteClient(protocol string, host string, port int, prefix string) (*GraphiteClient, error)

func NewGraphiteNop

func NewGraphiteNop(host string, port int) *GraphiteClient

NewGraphiteNop is a factory method that returns a GraphiteClient struct but will not actually try to send any packets to a remote host and, instead, will just log. This is useful if you want to use GraphiteClient in a project but don't want to make GraphiteClient a requirement for the project.

func NewGraphiteUDP

func NewGraphiteUDP(host string, port int) (*GraphiteClient, error)

When a UDP connection to GraphiteClient is required

func NewGraphiteWithMetricPrefix

func NewGraphiteWithMetricPrefix(host string, port int, prefix string) (*GraphiteClient, error)

NewGraphiteWithMetricPrefix is a factory method that's used to create a new GraphiteClient with a metric prefix

func (*GraphiteClient) Connect

func (gc *GraphiteClient) Connect() error

Given a GraphiteClient struct, Connect populates the GraphiteClient.conn field with an appropriate TCP connection

func (*GraphiteClient) Disconnect

func (gc *GraphiteClient) Disconnect() error

Given a GraphiteClient struct, Disconnect closes the GraphiteClient.conn field

func (*GraphiteClient) IsNop

func (gc *GraphiteClient) IsNop() bool

IsNop is a getter for *graphite.GraphiteClient.nop

func (*GraphiteClient) SendMetric

func (gc *GraphiteClient) SendMetric(metric Metric) error

Given a Metric struct, the SendMetric method sends the supplied metric to the GraphiteClient connection that the method is called upon

func (*GraphiteClient) SendMetrics

func (gc *GraphiteClient) SendMetrics(metrics []Metric) error

Given a slice of Metrics, the SendMetrics method sends the metrics, as a batch, to the GraphiteClient connection that the method is called upon

func (*GraphiteClient) SimpleSend

func (gc *GraphiteClient) SimpleSend(stat string, value string) bool

The SimpleSend method can be used to just pass a metric name and value and have it be sent to the GraphiteClient host with the current timestamp

func (*GraphiteClient) SimpleSendInt

func (gc *GraphiteClient) SimpleSendInt(stat string, value int) bool

type Metric

type Metric struct {
	Name      string
	Value     string
	Timestamp int64
}

Metric is a struct that defines the relevant properties of a graphite metric

func NewMetric

func NewMetric(name, value string, timestamp int64) Metric

func (Metric) String

func (metric Metric) String() string

Jump to

Keyboard shortcuts

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