Documentation ¶
Overview ¶
Package metrics provides routines for conveniently reporting metrics attached to SSF spans.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Report ¶
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.
Example ¶
package main import ( "github.com/stripe/veneur/ssf" "github.com/stripe/veneur/trace" "github.com/stripe/veneur/trace/metrics" ) func main() { // 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)) }
Output:
func ReportAsync ¶
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.
Example ¶
package main import ( "github.com/stripe/veneur/ssf" "github.com/stripe/veneur/trace" "github.com/stripe/veneur/trace/metrics" ) func main() { // 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 }
Output:
func ReportBatch ¶
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 ¶
ReportOne sends a single metric to a veneur using a trace client without waiting for a reply.
Example ¶
package main import ( "github.com/stripe/veneur/ssf" "github.com/stripe/veneur/trace" "github.com/stripe/veneur/trace/metrics" ) func main() { // Let's report a single metric (without any batching) using // the default client: metrics.ReportOne(trace.DefaultClient, ssf.Count("a.oneoff.counter", 1, nil)) }
Output: