Sampling is a process that restricts the amount of spans that are generated by a system. The exact sampler you should use depends on your specific needs, but in general you should make a decision at the start of a trace, and allow the sampling decision to propagate to other services.
provider := trace.NewTracerProvider(
are self-explanatory values.
AlwaysSample means that every span is sampled,
NeverSample means that no span is sampled. When you’re getting started,
or in a development environment, use
Other samplers include:
TraceIDRatioBased, which samples a fraction of spans, based on the fraction given to the sampler. If you set .5, half of all the spans are sampled.
ParentBased, is a sampler decorator which behaves differently, based on the parent of the span. If the span has no parent, the decorated sampler is used to make sampling decision based on the parent of the span. By default,
ParentBasedsamples spans that have parents that were sampled, and doesn’t sample spans whose parents were not sampled.
By default, the tracer provider uses a
ParentBased sampler with the
When in a production environment, consider using the
ParentBased sampler with