Module: Langfuse::Sampling Private

Defined in:
lib/langfuse/sampling.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Shared sampling helpers for trace and score emission.

Class Method Summary collapse

Class Method Details

.build_sampler(sample_rate) ⇒ OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build the sampler used by both trace export and trace-linked score emission.

Parameters:

  • sample_rate (Float)

    Sampling rate from 0.0 to 1.0

Returns:

  • (OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased, nil)


14
15
16
17
18
# File 'lib/langfuse/sampling.rb', line 14

def build_sampler(sample_rate)
  return nil if sample_rate >= 1.0

  OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased.new(sample_rate)
end