Skip to content

Commit

Permalink
Add debug mode hooks for adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Jul 21, 2021
1 parent d4ee604 commit 00ebff7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/yabeda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def debug!
buckets: [0.0001, 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60].freeze,
comment: "A histogram for the time required to evaluate collect blocks"
end

adapters.each_value(&:debug!)

true
end
# rubocop: enable Metrics/MethodLength, Metrics/AbcSize
Expand Down
3 changes: 3 additions & 0 deletions lib/yabeda/base_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ def register_histogram!(_metric)
def perform_histogram_measure!(_metric, _tags, _value)
raise NotImplementedError, "#{self.class} doesn't support measuring histograms"
end

# Hook to enable debug mode in adapters when it is enabled in Yabeda itself
def debug!; end
end
end
4 changes: 3 additions & 1 deletion spec/yabeda_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
describe ".collect!" do
subject(:collect!) { described_class.collect! }

let(:adapter) { instance_double("Yabeda::BaseAdapter", perform_histogram_measure!: true, register!: true) }
let(:adapter) do
instance_double("Yabeda::BaseAdapter", perform_histogram_measure!: true, register!: true, debug!: true)
end
let(:collector) do
proc do
sleep(0.01)
Expand Down

0 comments on commit 00ebff7

Please sign in to comment.