[−][src]Module opentelemetry::api::trace::sampler
OpenTelemetry Sampler Interface
Sampling
Sampling is a mechanism to control the noise and overhead introduced by OpenTelemetry by reducing the number of samples of traces collected and sent to the backend.
Sampling may be implemented on different stages of a trace collection.
OpenTelemetry API defines a Sampler interface that can be used at
instrumentation points by libraries to check the sampling SamplingDecision early and
optimize the amount of telemetry that needs to be collected.
All other sampling algorithms may be implemented on SDK layer in exporters, or even out of process in Agent or Collector.
The OpenTelemetry API has two properties responsible for the data collection:
is_recordingmethod on aSpan. Iftruethe currentSpanrecords tracing events (attributes, events, status, etc.), otherwise all tracing events are dropped. Users can use this property to determine if expensive trace events can be avoided.SpanProcessors will receive all spans with this flag set. However,SpanExporters will not receive them unless theSampledflag was set.Sampledflag intrace_flagsonSpanContext. This flag is propagated via theSpanContextto child Spans. For more details see the W3C specification. This flag indicates that theSpanhas beensampledand will be exported.SpanProcessors andSpanExporters will receive spans with theSampledflag set for processing.
The flag combination SampledFlag == false and is_recording == truemeans that the currentSpandoes record information, but most likely the childSpan` will not.
The flag combination SampledFlag == true and IsRecording == false
could cause gaps in the distributed trace, and because of this OpenTelemetry API
MUST NOT allow this combination.
Structs
| SamplingResult | The result of sampling logic for a given |
Enums
| SamplingDecision | Decision about whether or not to sample |
Traits
| Sampler | The |