report

package
v0.0.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

Metrics Reporting Helper

A thin wrapper around go-metrics that streamlines setup and a few common uses (tracking event rates and timings) and exports to graphite.

Usage

  r := report.NewRecorder().ReportTo("graphite-collector:2170", "foobar.baz")
  r.Inc("request")
  r.Time("handler", 5*time.Second)
Default Recorder

Alternately, rather than pass around a Recorder instance, you can also set a configured Recorder as the default during startup, then use helpers elsewhere that just report to the default recorder.

  report.NewRecorder().ReportTo("graphite-collector:2170", "foobar.baz").SetAsDefault()
  ...
  report.Inc("request")
  report.Time("handler", 5*time.Second)

Authors

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExportFormats = GoMetricsFormats
View Source
var GoMetricsFormats = ExportFormatStrings{
	Counter:        "%s.%s.count %d %s\n",
	HistogramCount: "%s.%s.count %d %s\n",
	Gauge:          "%s.%s.value %d %s\n",
	GaugeFloat64:   "%s.%s.value %f %s\n",
	Min:            "%s.%s.min %d %s\n",
	Max:            "%s.%s.max %d %s\n",
	Mean:           "%s.%s.mean %.2f %s\n",
	Stddev:         "%s.%s.std-dev %.2f %s\n",
	Percentile:     "%s.%s.%s-percentile %.2f %s\n",
	Rate1:          "%s.%s.one-minute %.2f %s\n",
	Rate5:          "%s.%s.five-minute %.2f %s\n",
	Rate15:         "%s.%s.fifteen-minute %.2f %s\n",
}
View Source
var OstrichFormats = ExportFormatStrings{
	Counter:        "%s.%s.count %d %s\n",
	HistogramCount: "%s.%s.count %d %s\n",
	Gauge:          "%s.%s.value %d %s\n",
	GaugeFloat64:   "%s.%s.value %f %s\n",
	Min:            "%s.%s.min %d %s\n",
	Max:            "%s.%s.max %d %s\n",
	Mean:           "%s.%s.mean %.2f %s\n",
	Stddev:         "%s.%s.std-dev %.2f %s\n",
	Percentile:     "%s.%s.percentiles.p%s %.2f %s\n",
	Rate1:          "%s.%s.one-minute %.2f %s\n",
	Rate5:          "%s.%s.five-minute %.2f %s\n",
	Rate15:         "%s.%s.fifteen-minute %.2f %s\n",
}

An alternate export format that formats percentile paths more like twitter's ostrich.

Functions

func Flag

func Flag() *string

func Inc

func Inc(name string)

func Time

func Time(name string, du time.Duration)

func TimeSince

func TimeSince(name string, t time.Time)

Types

type ClearableTimer

type ClearableTimer struct {
	metrics.Timer
	// contains filtered or unexported fields
}

func (*ClearableTimer) Clear

func (c *ClearableTimer) Clear()

type ExportFormatStrings

type ExportFormatStrings struct {
	Counter        string
	HistogramCount string
	Gauge          string
	GaugeFloat64   string
	Min            string
	Max            string
	Mean           string
	Stddev         string
	Percentile     string
	Rate1          string
	Rate5          string
	Rate15         string
}

type Guage

type Guage interface {
	metrics.Gauge
}

type Histogram

type Histogram interface {
	metrics.Histogram
}

type Meter

type Meter interface {
	metrics.Meter
}

type Recorder

type Recorder struct {
	metrics.Registry
	Format       ExportFormatStrings
	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
	// contains filtered or unexported fields
}

func GetDefault

func GetDefault() *Recorder

func NewRecorder

func NewRecorder() *Recorder

func (*Recorder) EnableGCInfoCollection

func (r *Recorder) EnableGCInfoCollection() *Recorder

func (*Recorder) FlushNow

func (r *Recorder) FlushNow()

func (*Recorder) GetGuage

func (r *Recorder) GetGuage(name string) Guage

func (*Recorder) GetHistogram

func (r *Recorder) GetHistogram(name string) Histogram

func (*Recorder) GetMeter

func (r *Recorder) GetMeter(name string) Meter

func (*Recorder) GetTimer

func (r *Recorder) GetTimer(name string) Timer

func (*Recorder) Inc

func (r *Recorder) Inc(name string)

func (*Recorder) LogToConsole

func (r *Recorder) LogToConsole(freq time.Duration) *Recorder

func (*Recorder) MaybeReportTo

func (r *Recorder) MaybeReportTo(serverSlashPrefix *string) *Recorder

func (*Recorder) RegisterGuageValue

func (r *Recorder) RegisterGuageValue(name string, reportEvery time.Duration, get func() float64)

func (*Recorder) RegisterHttp

func (r *Recorder) RegisterHttp() *Recorder

func (*Recorder) ReportTo

func (r *Recorder) ReportTo(serverSlashPrefix string) *Recorder

func (*Recorder) ReportToServer

func (r *Recorder) ReportToServer(graphiteServer, graphitePrefix string) *Recorder

func (*Recorder) ServeHTTP

func (r *Recorder) ServeHTTP(out http.ResponseWriter, req *http.Request)

func (*Recorder) SetAsDefault

func (r *Recorder) SetAsDefault() *Recorder

func (*Recorder) Time

func (r *Recorder) Time(name string, du time.Duration)

func (*Recorder) TimeSince

func (r *Recorder) TimeSince(name string, t time.Time)

type Timer

type Timer interface {
	metrics.Timer
}

Jump to

Keyboard shortcuts

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