Sha256: 415c40071d3332fdd5aa66732402d8ce7c4355451fad1a7fee27866367119fa4

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

# frozen_string_literal: true

module Chronicle
  module ETL
    class SamplerTransformer < Chronicle::ETL::Transformer
      register_connector do |r|
        r.identifier = :sampler
        r.description = 'by taking a sample'
      end

      setting :percent, default: 10, type: :numeric

      # return the result, `percent` percentage of the time. otherwise nil
      def transform(record)
        return unless rand(100) < @config.percent

        record.data
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronicle-etl-0.6.1 lib/chronicle/etl/transformers/sampler_transformer.rb