sampler

package
v0.0.0-...-5861b17 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sampler offers a Sampler that looks for a TraceID.Valid() == true or a gRPC metadata key called "trace" and if they exist will sample. Otherwise it looks to a child Sampler to determine based upon whatever sampler algorithm is used.

In addition we offer the ability to switch out the underlying sampler at anytime in a thread-safe way.

You can construct a new Sampler like so:

s, err := New(trace.NeverSample)
if err != nil {
	// Do something
}

The above Sampler would only trace if a TraceID.Valid() == true or gRCP metadate key called "trace" existed.

If we want to trace 1% of the time as well, we can do the following:

s, err := New(trace.TraceIDRatioBased(.01))
if err != nil {
	// Do something
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sampler

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

Sampler decides whether a trace should be sampled and exported. This sampler will sample if paramters TraceID.Valid() == true or the Context contains gRPC metadata that has key "trace" (it doesn't care about values).

func New

func New(child trace.Sampler) (*Sampler, error)

New creates a new Sampler with the child Sampler used if TraceID.Valid() == false and gRPC metadata does not contain key "trace".

func (*Sampler) Description

func (s *Sampler) Description() string

Description implements trace.Sampler.Description().

func (*Sampler) ShouldSample

ShouldSample implements trace.Sampler.ShouldSample.

func (*Sampler) Switch

func (s *Sampler) Switch(sampler trace.Sampler)

Switch switches the underlying trace.Sampler.

Jump to

Keyboard shortcuts

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