metrics

package
v13.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: MIT Imports: 2 Imported by: 53

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

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.

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

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.

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

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

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.

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:

Types

type NoMetrics

type NoMetrics struct{}

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

func (NoMetrics) Error

func (nm NoMetrics) Error() string

Jump to

Keyboard shortcuts

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