metrics

package module
v0.0.0-...-908577f Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 7 Imported by: 7

README

go-metrics

This is a stupid simple wrapper around the Librato go library. There are only three functions, the ones we use the most often.

Example Usage

func init() {
    metrics.Namespace = "api"
    source := "prod.web.1"
    metrics.Start(source)
}

metrics.Increment("signup")
start := time.Now()
time.Sleep(3*time.Second)
metrics.Time("long_op", time.Since(start))

metrics.Measure("queue_depth", 57)

Configuration

Set LIBRATO_TOKEN in your environment; this gets passed to the librato client and will publish metrics every ten seconds.

Debugging

Set DEBUG=metrics in your environment to print all metrics to stdout in realtime.

Documentation

Overview

The metrics package instruments your code.

Set DEBUG=metrics environment variable to print metrics to stdout.

Index

Examples

Constants

View Source
const Version = "1.1"

Variables

View Source
var Namespace string

Namespace is the namespace under which all metrics will get incremented. Typically this should match up with the running service ("api", "admin", "jobs", "parcels", &c).

Functions

func Increment

func Increment(name string)

Increment a counter with the given name.

Example
Start("web", "test@example.com")
Increment("dequeue.success")
Output:

func Measure

func Measure(name string, value int64)

Measure that the given metric has the given value.

Example
Start("web", "test@example.com")
Measure("workers.active", 6)
Output:

func Start

func Start(source string, email string)

Start initializes the metrics client. You must call this before sending metrics, or metrics will not get published to Librato.

func Time

func Time(name string, value time.Duration)

Add a new timing measurement for the given metric.

Example
Start("web", "test@example.com")
start := time.Now()
time.Sleep(3)
Time("auth.latency", time.Since(start))
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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