struct OpenTelemetry::Sampler::TraceIdRatioBased
- OpenTelemetry::Sampler::TraceIdRatioBased
- OpenTelemetry::InheritableSampler
- OpenTelemetry::Sampler
- Struct
- Value
- Object
Overview
This sampler will only record a subset of the total number of traces. It can be initialized with either a decimal ratio or a fraction. Examples:
# Record 10% of the total traces
sampler = OpenTelemetry::Sampler::TraceIdRatioBased.new(0.1)
# Record 50% of the total traces
sampler = OpenTelemetry::Sampler::TraceIdRatioBased.new(0.5)
# Record 1/30th of the total traces
sampler = OpenTelemetry::Sampler::TraceIdRatioBased.new(1, 30)
It uses CRC32 for the hashing/randomization algorithm. CRC32 is dramatically faster than algorithms like MD5 or SHA1, and it produces a more uniform distribution of the bits for trace id input data than does any of the readily available cryptographic hashing algorithms. It is surprisingly good for this purpose.
Defined in:
samplers/trace_id_ratio_based.crConstant Summary
-
BlankId =
Slice(UInt8).new(16, 0)
Constructors
Instance Method Summary
-
#description : String
This should probably be overridden with a specific, appropriate name.
- #description? : String | Nil
- #initialize_impl(ratio : Float64)
Instance methods inherited from struct OpenTelemetry::Sampler
description
description,
get_description
get_description,
should_sample(context : SpanContext, name : String = "", trace_id : Slice(UInt8) | Nil = nil, kind : OpenTelemetry::Span::Kind = OpenTelemetry::Span::Kind::Internal, attributes : Hash(String, AnyAttribute) = {} of String => AnyAttribute, links : Nil = nil) : SamplingResultshould_sample(span) should_sample, to_s(io) to_s
Constructor methods inherited from struct OpenTelemetry::Sampler
new(arg = nil)
new
Constructor Detail
Instance Method Detail
Description copied from struct OpenTelemetry::Sampler
This should probably be overridden with a specific, appropriate name.