veneur: github.com/stripe/veneur/trace/metrics Index | Examples | Files

package metrics

import "github.com/stripe/veneur/trace/metrics"

Package metrics provides routines for conveniently reporting metrics attached to SSF spans.

Index

Examples

Package Files

client.go

func Report Uses

func Report(cl *trace.Client, samples *ssf.Samples) error

Report sends one-off metric samples encapsulated in a Samples structure to a trace client without waiting for a reply. If the batch of metrics is empty, an error NoMetrics is returned.

Code:

// Create a slice of metrics and report them in one batch at the end of the function:
samples := &ssf.Samples{}
defer metrics.Report(trace.DefaultClient, samples)

// Let's add some metrics to the batch:
samples.Add(ssf.Count("a.counter", 2, nil))
samples.Add(ssf.Gauge("a.gauge", 420, nil))

func ReportAsync Uses

func ReportAsync(cl *trace.Client, metrics []*ssf.SSFSample, done chan<- error) error

ReportAsync sends a batch of one-off metrics to a trace client asynchronously. The channel done receives an error (or nil) when the span containing the batch of metrics has been sent.

If metrics is empty, an error NoMetrics is returned and done does not receive any data.

Code:

// Create a slice of metrics and report them in one batch at the end of the function:
samples := []*ssf.SSFSample{}

// Let's add some metrics to the batch:
samples = append(samples, ssf.Count("a.counter", 2, nil))
samples = append(samples, ssf.Gauge("a.gauge", 420, nil))

// report the batch:
done := make(chan error)
metrics.ReportAsync(trace.DefaultClient, samples, done)
// ... and wait for it to send:
<-done

func ReportBatch Uses

func ReportBatch(cl *trace.Client, samples []*ssf.SSFSample) error

ReportBatch sends a batch of one-off metrics to a trace client without waiting for a reply. If the batch of metrics is empty, an error NoMetrics is returned.

func ReportOne Uses

func ReportOne(cl *trace.Client, metric *ssf.SSFSample) error

ReportOne sends a single metric to a veneur using a trace client without waiting for a reply.

Code:

// Let's report a single metric (without any batching) using
// the default client:
metrics.ReportOne(trace.DefaultClient, ssf.Count("a.oneoff.counter", 1, nil))

type NoMetrics Uses

type NoMetrics struct{}

NoMetrics indicates that no metrics were included in the batch of metrics to submit.

func (NoMetrics) Error Uses

func (nm NoMetrics) Error() string

Package metrics imports 2 packages (graph) and is imported by 16 packages. Updated 2018-12-03. Refresh now. Tools for package owners.