Do not notify Bugsnag of a cache miss

It's not the responsibility of a error tracking software to track
neither cache misses nor logs. That is what log monitoring is for.
This commit is contained in:
Pau Perez
2017-11-02 16:52:49 +01:00
parent 98603c4042
commit 84e4ebef08
2 changed files with 0 additions and 38 deletions

View File

@@ -26,17 +26,9 @@ module OpenFoodNetwork
private
def log_warning
if Rails.env.production? || Rails.env.staging?
Bugsnag.notify RuntimeError.new("Live server MISS on products cache for distributor: #{@distributor.id}, order cycle: #{@order_cycle.id}")
end
end
def cached_products_json
if Rails.env.production? || Rails.env.staging?
Rails.cache.fetch("products-json-#{@distributor.id}-#{@order_cycle.id}") do
log_warning
begin
uncached_products_json
rescue ProductsRenderer::NoProducts

View File

@@ -77,11 +77,6 @@ module OpenFoodNetwork
cpr.products_json
expect(cached_json).to eq 'fresh products'
end
it "logs a warning" do
cpr.should_receive :log_warning
cpr.products_json
end
end
describe "when there are no products" do
@@ -104,34 +99,9 @@ module OpenFoodNetwork
expect(cache_present).to be
expect(cached_json).to be_nil
end
it "logs a warning" do
cpr.should_receive :log_warning
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
end
end
end
end
describe "logging a warning" do
it "logs a warning when in production" do
Rails.env.stub(:production?) { true }
expect(Bugsnag).to receive(:notify)
cpr.send(:log_warning)
end
it "logs a warning when in staging" do
Rails.env.stub(:production?) { false }
Rails.env.stub(:staging?) { true }
expect(Bugsnag).to receive(:notify)
cpr.send(:log_warning)
end
it "does not log a warning in development or test" do
expect(Bugsnag).to receive(:notify).never
cpr.send(:log_warning)
end
end
end
end