This section is empty.


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


This section is empty.


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.