Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default RuleSampler rate_limit of 100 #898

Merged
merged 2 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ddtrace/sampling/rule_sampler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class RuleSampler
attr_reader :rules, :rate_limiter, :default_sampler

# @param rules [Array<Rule>] ordered list of rules to be applied to a span
# @param rate_limit [Float] number of traces per second, defaults to no rate limit
# @param rate_limit [Float] number of traces per second, defaults to +100+
# @param rate_limiter [RateLimiter] limiter applied after rule matching
# @param default_sample_rate [Float] fallback sample rate when no rules apply to a span,
# between +[0,1]+, defaults to +1+
# @param default_sampler [Sample] fallback strategy when no rules apply to a span
def initialize(rules = [],
rate_limit: nil,
rate_limit: 100,
brettlangdon marked this conversation as resolved.
Show resolved Hide resolved
rate_limiter: nil,
default_sample_rate: nil,
default_sampler: nil)
Expand Down
8 changes: 7 additions & 1 deletion spec/ddtrace/sampling/rule_sampler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
context '#initialize' do
subject(:rule_sampler) { described_class.new(rules) }

it { expect(subject.rate_limiter).to be_a(Datadog::Sampling::UnlimitedLimiter) }
it { expect(subject.rate_limiter).to be_a(Datadog::Sampling::TokenBucket) }
it { expect(subject.default_sampler).to be_a(Datadog::AllSampler) }

context 'with rate_limit' do
Expand All @@ -32,6 +32,12 @@
it { expect(subject.rate_limiter).to be_a(Datadog::Sampling::TokenBucket) }
end

context 'with nil rate_limit' do
subject(:rule_sampler) { described_class.new(rules, rate_limit: nil) }

it { expect(subject.rate_limiter).to be_a(Datadog::Sampling::UnlimitedLimiter) }
end

context 'with default_sample_rate' do
subject(:rule_sampler) { described_class.new(rules, default_sample_rate: 1.0) }

Expand Down