sample

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSampleRate = errors.New("sample rate must be >= 1")
)

Functions

This section is empty.

Types

type DeterministicSampler

type DeterministicSampler struct {
	// contains filtered or unexported fields
}

DeterministicSampler allows for distributed sampling based on a common field such as a request or trace ID. It accepts a sample rate N and will deterministically sample 1/N events based on the target field. Hence, two or more programs can decide whether or not to sample related events without communication.

var GlobalSampler *DeterministicSampler

If you want a globally active sampler, make a new one and set it here. It will then be usable globally. If you'd rather not have global state, ignore it - this won't get set automatically.

func NewDeterministicSampler

func NewDeterministicSampler(sampleRate uint) (*DeterministicSampler, error)

func (*DeterministicSampler) GetSampleRate

func (ds *DeterministicSampler) GetSampleRate() int

GetSampleRate is an accessor to find out how this sampler was initialized

func (*DeterministicSampler) Sample

func (ds *DeterministicSampler) Sample(determinant string) bool

Sample returns true when you should *keep* this sample. False when it should be dropped.

Jump to

Keyboard shortcuts

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