Documentation ¶
Overview ¶
Package graphite contains the functionality for sending metrics to a Graphite server.
Index ¶
Constants ¶
const ( // DefaultMaxBufferSize is the default maximum number of metrics to buffer // before sending them to the Graphite server. DefaultMaxBufferSize = 1000 // DefaultMaxMetricsPerMessage is the default maximum number of metrics to // send to the Graphite server in a single request. DefaultMaxMetricsPerMessage = 1 // DefaultMaxTries is the default maximum number of times to try sending // metrics to the Graphite server. DefaultMaxTries = 3 )
Variables ¶
var ( // ErrNoAddress is returned when no server address is specified for the // Graphite client. ErrNoAddress = errors.New( "graphite: no address specified for Graphite server", ) )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // SendMetric sends a metric to the Graphite server. SendMetric(ctx context.Context, metric MetricMetadata, value string, timestamp time.Time, ) error // Submit submits the queued metrics to the Graphite server. Submit(ctx context.Context) error }
Client is the interface defining a Graphite client.
type ClientOption ¶
type ClientOption func(c *clientOptions)
ClientOption represents an option that can be set on the Graphite client.
func WithAddress ¶
func WithAddress(addr url.URL) ClientOption
WithAddress sets the address of the Graphite server. This is used if [Conn] is not set.
func WithConnection ¶
func WithConnection(conn net.Conn) ClientOption
WithConnection sets the connection to use when sending metrics to the Graphite server.
func WithMaxBufferSize ¶
func WithMaxBufferSize(maxBufferSize int) ClientOption
WithMaxBufferSize sets the maximum number of metrics to buffer before sending them to the Graphite server.
func WithMaxMetricsPerMessage ¶
func WithMaxMetricsPerMessage(maxMetricsPerMessage int) ClientOption
WithMaxMetricsPerMessage sets the maximum number of metrics to send to the Graphite server in a single request.
func WithMaxTries ¶
func WithMaxTries(maxTries int) ClientOption
WithMaxTries sets the maximum number of times to retry sending metrics to the Graphite server.
type Metric ¶
type Metric struct { MetricMetadata Value string Timestamp time.Time }
Metric represents a metric that has been queued for sending to the Graphite server.
type MetricMetadata ¶
MetricMetadata represents a metric that can be sent to a Graphite server.
func (MetricMetadata) SubMetric ¶
func (m MetricMetadata) SubMetric(name string, tags map[string]string) *MetricMetadata
SubMetric returns a new metric metadata with the given name appended to the current metric's name. This allows child metrics to be created from a parent metric.