Goal: provide tools to make testing that Yabeda metrics are being changed as expected to be convenient and allow users not to rely on Yabeda internals that are going to change
Usage with RSpec
Add the following to your rails_helper.rb (or spec_helper.rb):
require "yabeda/rspec"
Now you can use increment_yabeda_counter, update_yabeda_gauge, and measure_yabeda_histogram matchers:
it "increments counters" do
expect { subject }.to increment_yabeda_counter(Yabeda.myapp.foo_count).by(3)
end
You can scope metrics by used tags with with_tags:
it "updates gauges" do
expect { subject }.to \
update_yabeda_gauge("some_gauge_name").
with_tags(method: "command", command: "subscribe")
end
Note that tags you specified doesn't need to be exact, but can be a subset of tags used on metric update. In this example updates with following sets of tags { method: "command", command: "subscribe", status: "SUCCESS" } and { method: "command", command: "subscribe", status: "FAILURE" } will make test example to pass.
And check for values with by for counters, to for gauges, and with for gauges and histograms (and you can use other matchers here):
Goal: provide tools to make testing that Yabeda metrics are being changed as expected to be convenient and allow users not to rely on Yabeda internals that are going to change
Usage with RSpec
Add the following to your
rails_helper.rb
(orspec_helper.rb
):Now you can use
increment_yabeda_counter
,update_yabeda_gauge
, andmeasure_yabeda_histogram
matchers:You can scope metrics by used tags with
with_tags
:Note that tags you specified doesn't need to be exact, but can be a subset of tags used on metric update. In this example updates with following sets of tags
{ method: "command", command: "subscribe", status: "SUCCESS" }
and{ method: "command", command: "subscribe", status: "FAILURE" }
will make test example to pass.And check for values with
by
for counters,to
for gauges, andwith
for gauges and histograms (and you can use other matchers here):