graphite

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Once

func Once(c *Config, r metrics.Registry) error

Once performs a single submission to Graphite, returning a non-nil error on failed connections. This can be used in a loop similar to GraphiteWithConfig for custom error handling.

Types

type Config

type Config struct {
	Host           string        `toml:"host" yaml:"host" json:"host"`                                  // Network address to connect to
	FlushInterval  time.Duration `toml:"interval" yaml:"interval" json:"interval"`                      // Flush interval
	DurationUnit   time.Duration `toml:"duration" yaml:"duration" json:"duration"`                      // Time conversion unit for durations
	Prefix         string        `toml:"prefix" yaml:"prefix" json:"prefix"`                            // Prefix to be prepended to metric names
	TagPrefix      string        `toml:"tag_prefix" yaml:"tag_prefix" json:"tag_prefix"`                // Prefix to be prepended to metric name tag
	ConnectTimeout time.Duration `toml:"connect_timeout" yaml:"connect_timeout" json:"connect_timeout"` // Connect timeout
	Timeout        time.Duration `toml:"timeout" yaml:"timeout" json:"timeout"`                         // Write timeout
	Retry          int           `toml:"retry" yaml:"retry" json:"retry"`                               // Reconnect retry count
	BufSize        int           `toml:"buffer" yaml:"buffer" json:"buffer"`                            // Buffer size

	MinLock bool `toml:"min_lock" yaml:"min_lock" json:"min_lock"` // Minimize time of read-locking of metric registry (but with some costs), set if application do dynamic metrics register/unregister

	Percentiles []float64 `toml:"percentiles" yaml:"percentiles" json:"percentiles"` // Percentiles to export from timers and histograms

	Tags map[string]string `toml:"tags" yaml:"tags" json:"tags"` // Tags for sended metrics (not used directky in graphite client, merge it with  metric individual tags)
	// contains filtered or unexported fields
}

Config provides a container with configuration parameters for the Graphite exporter

type Graphite

type Graphite struct {
	// contains filtered or unexported fields
}
Example
g := New(1*time.Second, "some.prefix", "127.0.0.1:2003", time.Second)
g.Start(metrics.DefaultRegistry)
g.Stop()
Output:

func New

func New(flushInterval time.Duration, prefix string, host string, timeout time.Duration) *Graphite

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

func WithConfig

func WithConfig(c *Config) *Graphite

WithConfig is a blocking exporter function just like Graphite, but it takes a GraphiteConfig instead.

Example
g := WithConfig(&Config{
	Host:          "127.0.0.1:2003",
	FlushInterval: 1 * time.Second,
	DurationUnit:  time.Millisecond,
	Percentiles:   []float64{0.5, 0.75, 0.99, 0.999},
})
g.Start(metrics.DefaultRegistry)
g.Stop()
Output:

func (*Graphite) Close

func (g *Graphite) Close() error

func (*Graphite) SetLoggerError

func (g *Graphite) SetLoggerError(f func(error))

func (*Graphite) SetLoggerSucces

func (g *Graphite) SetLoggerSucces(f func())

func (*Graphite) Start

func (g *Graphite) Start(r metrics.Registry)

func (*Graphite) Stop

func (g *Graphite) Stop()

Jump to

Keyboard shortcuts

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