Honeylixir.DeterminsticSampler (honeylixir v0.6.1) View Source

Provides a helper function for sampling consistently for use in the sample_hook.

This code is an Elixir implemenation of the official beeline-ruby one found here: https://github.com/honeycombio/beeline-ruby/blob/v2.4.0/lib/honeycomb/deterministic_sampler.rb

Link to this section Summary

Functions

Determines if this event should be sampled based on the field given. This way, you can deterministically sample given the same value and sample rate with every invocation.

Link to this section Functions

Link to this function

should_sample?(rate, value)

View Source

Specs

should_sample?(integer(), String.Chars.t()) :: boolean()

Determines if this event should be sampled based on the field given. This way, you can deterministically sample given the same value and sample rate with every invocation.

Examples

iex> Honeylixir.DeterminsticSampler.should_sample?(3, "foo") true

iex> Honeylixir.DeterminsticSampler.should_sample?(3, "bar") false

iex> Honeylixir.DeterminsticSampler.should_sample?(1, "bar") true

iex> Honeylixir.DeterminsticSampler.should_sample?(0, "foo") false