[deploy] Honeycomb instrumentation: distinguish between literal vs prefix matching for sampling (#7936)
This commit is contained in:
parent
6a4a99f162
commit
a6305fd0a3
2 changed files with 17 additions and 2 deletions
|
|
@ -7,19 +7,24 @@ module Honeycomb
|
|||
"TIME",
|
||||
"BEGIN",
|
||||
"COMMIT",
|
||||
].freeze
|
||||
|
||||
NOISY_PREFIXES = [
|
||||
"INCRBY",
|
||||
"TTL",
|
||||
"GET rack:",
|
||||
"SET rack:",
|
||||
"GET views/shell",
|
||||
].freeze
|
||||
|
||||
def self.sample(fields)
|
||||
if NOISY_COMMANDS.include?(fields["redis.command"]) || NOISY_COMMANDS.include?(fields["sql.active_record.sql"])
|
||||
if (NOISY_COMMANDS & [fields["redis.command"], fields["sql.active_record.sql"]]).any?
|
||||
rate = 100
|
||||
[should_sample(rate, fields["trace.trace_id"]), rate]
|
||||
elsif fields["redis.command"]&.start_with?("BRPOP")
|
||||
rate = 1000
|
||||
[should_sample(rate, fields["trace.trace_id"]), rate]
|
||||
elsif fields["redis.command"]&.start_with?("INCRBY") || fields["redis.command"]&.start_with?("TTL")
|
||||
elsif fields["redis.command"]&.start_with?(*NOISY_PREFIXES)
|
||||
rate = 100
|
||||
[should_sample(rate, fields["trace.trace_id"]), rate]
|
||||
else
|
||||
|
|
|
|||
|
|
@ -28,6 +28,16 @@ RSpec.describe Honeycomb::NoiseCancellingSampler do
|
|||
described_class.sample({ "redis.command" => "TTL this and that", "trace.trace_id" => trace_id })
|
||||
expect(described_class).to have_received(:should_sample).with(100, trace_id)
|
||||
end
|
||||
|
||||
it "samples if the command starts with GET rack:" do
|
||||
described_class.sample({ "redis.command" => "GET rack::something", "trace.trace_id" => trace_id })
|
||||
expect(described_class).to have_received(:should_sample).with(100, trace_id)
|
||||
end
|
||||
|
||||
it "samples if the command starts with SET rack:" do
|
||||
described_class.sample({ "redis.command" => "SET rack::something", "trace.trace_id" => trace_id })
|
||||
expect(described_class).to have_received(:should_sample).with(100, trace_id)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a active_record SQL command" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue