hs-opentelemetry-api-0.0.3.8: OpenTelemetry API for use by libraries for direct instrumentation or wrapper packages.
Copyright(c) Ian Duncan 2021
LicenseBSD-3
MaintainerIan Duncan
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

OpenTelemetry.Trace.Sampler

Description

This module provides several built-in sampling strategies, as well as the ability to define custom samplers.

Sampling is the concept of selecting a few elements from a large collection and learning about the entire collection by extrapolating from the selected set. It’s widely used throughout the world whenever trying to tackle a problem of scale: for example, a survey assumes that by asking a small group of people a set of questions, you can learn something about the opinions of the entire populace.

While it’s nice to believe that every event is precious, the reality of monitoring high volume production infrastructure is that there are some attributes to events that make them more interesting than the rest. Failures are often more interesting than successes! Rare events are more interesting than common events! Capturing some traffic from all customers can be better than capturing all traffic from some customers.

Sampling as a basic technique for instrumentation is no different—by recording information about a representative subset of requests flowing through a system, you can learn about the overall performance of the system. And as with surveys and air monitoring, the way you choose your representative set (the sample set) can greatly influence the accuracy of your results.

Sampling is widespread in observability systems because it lowers the cost of producing, collecting, and analyzing data in systems anywhere cost is a concern. Developers and operators in an observability system apply or attach key=value properties to observability data–spans and metrics–and we use these properties to investigate hypotheses about our systems after the fact. It is interesting to look at how sampling impacts our ability to analyze observability data, using key=value restrictions for some keys and grouping the output based on other keys.

Sampling schemes let observability systems collect examples of data that are not merely exemplary, but also representative. Sampling schemes compute a set of representative items and, in doing so, score each item with what is commonly called the item's "sampling rate." A sampling rate of 10 indicates that the item represents an estimated 10 individuals in the original data set.

Synopsis

Documentation

data Sampler Source #

Interface that allows users to create custom samplers which will return a sampling SamplingResult based on information that is typically available just before the Span was created.

Constructors

Sampler 

Fields

data SamplingResult Source #

The outcome of a call to Sampler indicating whether the Tracer should sample a Span.

Constructors

Drop

isRecording == false. Span will not be recorded and all events and attributes will be dropped.

RecordOnly

isRecording == true, but Sampled flag MUST NOT be set.

RecordAndSample

isRecording == true, AND Sampled flag MUST be set.

parentBased :: ParentBasedOptions -> Sampler Source #

A sampler which behaves differently based on the incoming sampling decision.

In general, this will sample spans that have parents that were sampled, and will not sample spans whose parents were not sampled.

Since: 0.1.0.0

parentBasedOptions Source #

Arguments

:: Sampler

Root sampler

-> ParentBasedOptions 

A smart constructor for ParentBasedOptions with reasonable starting defaults.

Since: 0.1.0.0

data ParentBasedOptions Source #

This is a composite sampler. ParentBased helps distinguish between the following cases:

No parent (root span).

Remote parent (SpanContext.IsRemote() == true) with SampledFlag equals true

Remote parent (SpanContext.IsRemote() == true) with SampledFlag equals false

Local parent (SpanContext.IsRemote() == false) with SampledFlag equals true

Local parent (SpanContext.IsRemote() == false) with SampledFlag equals false

Since: 0.1.0.0

Constructors

ParentBasedOptions 

Fields

traceIdRatioBased :: Double -> Sampler Source #

The TraceIdRatioBased ignores the parent SampledFlag. To respect the parent SampledFlag, the TraceIdRatioBased should be used as a delegate of the parentBased sampler specified below.

Description returns a string of the form "TraceIdRatioBased{RATIO}" with RATIO replaced with the Sampler instance's trace sampling ratio represented as a decimal number.

Since: 0.1.0.0

alwaysOn :: Sampler Source #

Returns RecordAndSample always.

Description returns AlwaysOnSampler.

Since: 0.1.0.0

alwaysOff :: Sampler Source #

Returns Drop always.

Description returns AlwaysOffSampler.

Since: 0.1.0.0