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 ¶
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 ¶
Description implements trace.Sampler.Description().
func (*Sampler) ShouldSample ¶
func (s *Sampler) ShouldSample(p trace.SamplingParameters) trace.SamplingResult
ShouldSample implements trace.Sampler.ShouldSample.