package
0.0.0-20240514141728-2113ccc707c7
Repository: https://github.com/zeim839/go-metrics-plus.git
Documentation: pkg.go.dev

# README

Graphite

Graphite is the Graphite driver for go-metrics-plus. It collects metrics from a registry and periodically posts them to a Graphite instance. The driver has been ported to go-metrics-plus (along with several bug fixes and optimizations) from cyberdelia's go-metrics-graphite project.

Usage

import "github.com/zeim839/go-metrics-plus/graphite"

// Sinks metrics every 1 second.
go graphite.Graphite(metrics.DefaultRegistry, 1*time.Second, "some.prefix", addr)

Example

import (
	"github.com/zeim839/go-metrics-plus"
	"github.com/zeim839/go-metrics-plus/graphite"
	"net"
	"time"
)

func ExampleGraphite() {
	addr, _ := net.ResolveTCPAddr("net", ":2003")
	go graphite.Graphite(metrics.DefaultRegistry, 1*time.Second, "some.prefix", addr)
}

func ExampleWithConfig() {
	addr, _ := net.ResolveTCPAddr("net", ":2003")
	go graphite.WithConfig(Config{
		Addr:          addr,
		Registry:      metrics.DefaultRegistry,
		FlushInterval: 1 * time.Second,
		DurationUnit:  time.Millisecond,
	})
}

# Functions

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.
Once performs a single submission to Graphite, returning a non-nil error on failed connections.
WithConfig is a blocking exporter function just like Graphite, but it takes a GraphiteConfig instead.

# Structs

Config provides a container with configuration parameters for the Graphite exporter.