[deploy] Optimization:Throttle Noisy Honeycomb Events More (#10143)

This commit is contained in:
Molly Struve 2020-09-01 15:21:07 -05:00 committed by GitHub
parent a5e7b1cf60
commit 79b00d4960
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -25,14 +25,14 @@ module Honeycomb
# should_sample is a no-op if the rate is 1
if fields["redis.command"].in? NOISY_REDIS_COMMANDS
rate = 100
rate = 300
elsif fields["sql.active_record.sql"].in? NOISY_SQL_COMMANDS
rate = 100
rate = 300
elsif fields["redis.command"]&.start_with?("BRPOP")
# BRPOP is disproportionately noisy and not really interesting
rate = 1000
rate = 5000
elsif fields["redis.command"]&.start_with?(*NOISY_REDIS_PREFIXES)
rate = 100
rate = 300
end
[should_sample(rate, fields["trace.trace_id"]), rate]
end

View file

@ -14,34 +14,34 @@ RSpec.describe Honeycomb::NoiseCancellingSampler do
it "samples if its in NOISY_REDIS_COMMANDS" do
is_sampled, rate = described_class.sample({ "redis.command" => "TIME", "trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(100)
expect(rate).to match(300)
end
it "samples if the command is BRPOP" do
is_sampled, rate = described_class.sample({ "redis.command" => "BRPOP", "trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(1000)
expect(rate).to match(5000)
end
it "samples if the command starts with TTL" do
is_sampled, rate = described_class.sample({ "redis.command" => "TTL this and that",
"trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(100)
expect(rate).to match(300)
end
it "samples if the command starts with GET rack:" do
is_sampled, rate = described_class.sample({ "redis.command" => "GET rack::something",
"trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(100)
expect(rate).to match(300)
end
it "samples if the command starts with SET rack:" do
is_sampled, rate = described_class.sample({ "redis.command" => "SET rack::something",
"trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(100)
expect(rate).to match(300)
end
end
@ -49,7 +49,7 @@ RSpec.describe Honeycomb::NoiseCancellingSampler do
it "samples if its in NOISY_SQL_COMMANDS" do
is_sampled, rate = described_class.sample({ "sql.active_record.sql" => "COMMIT", "trace.trace_id" => trace_id })
expect(is_sampled).to be_in [true, false]
expect(rate).to match(100)
expect(rate).to match(300)
end
end
end