statsd

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

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

Go to latest
Published: Sep 28, 2017 License: MIT Imports: 9 Imported by: 0

README

Intro

This library is based on the cyberdelia graphite library just modifying the wireformat for statsd

This is a reporter for the go-metrics library which will post the metrics to Statsd. It was originally part of the go-metrics library itself, but has been split off to make maintenance of both the core library and the client easier.

Usage

import "github.com/pubnub/go-metrics-statsd"


go statsd.StatsD(metrics.DefaultRegistry,
  1*time.Second, "some.prefix", addr)

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatsD

func StatsD(r metrics.Registry, d time.Duration, prefix string, addr *net.UDPAddr)

StatsD is a blocking exporter function which reports metrics in r to a statsd server located at addr, flushing them every d duration and prepending metric names with prefix.

Example
addr, _ := net.ResolveTCPAddr("net", ":2003")
go StatsD(metrics.DefaultRegistry, 1*time.Second, "some.prefix", addr)
Output:

func StatsDWithConfig

func StatsDWithConfig(c StatsDConfig)

StatsDWithConfig is a blocking exporter function just like StatsD, but it takes a StatsDConfig instead.

Example
addr, _ := net.ResolveTCPAddr("net", ":2003")
go StatsDWithConfig(StatsDConfig{
	Addr:          addr,
	Registry:      metrics.DefaultRegistry,
	FlushInterval: 1 * time.Second,
	DurationUnit:  time.Millisecond,
	Percentiles:   []float64{0.5, 0.75, 0.99, 0.999},
})
Output:

Types

type StatsDConfig

type StatsDConfig struct {
	Addr          *net.UDPAddr     // Network address to connect to
	Registry      metrics.Registry // Registry to be exported
	FlushInterval time.Duration    // Flush interval
	DurationUnit  time.Duration    // Time conversion unit for durations
	Prefix        string           // Prefix to be prepended to metric names
	Percentiles   []float64        // Percentiles to export from timers and histograms
}

StatsDConfig provides a container with configuration parameters for the StatsD exporter

Jump to

Keyboard shortcuts

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