sample

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 3 Imported by: 18

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