lib/alephant/broker/load_strategy/s3.rb in alephant-broker-3.0.1 vs lib/alephant/broker/load_strategy/s3.rb in alephant-broker-3.1.0
- old
+ new
@@ -1,19 +1,23 @@
require "alephant/broker/cache"
require 'alephant/broker/errors/content_not_found'
require 'alephant/broker/errors/invalid_cache_key'
+require 'alephant/logger'
module Alephant
module Broker
module LoadStrategy
class S3
+ include Logger
+
def load(component_meta)
add_s3_headers(
cache_object(component_meta),
component_meta
)
rescue
+ logger.metric(:name => "BrokerLoadStrategyS3CacheMiss", :unit => "Count", :value => 1)
add_s3_headers(
cache.set(
component_meta.cache_key,
retrieve_object(component_meta)
),
@@ -43,9 +47,10 @@
def retrieve_object(component_meta)
component_meta.cached = false
s3.get s3_path(component_meta)
rescue AWS::S3::Errors::NoSuchKey, InvalidCacheKey
+ logger.metric(:name => "BrokerLoadStrategyS3InvalidCacheKey", :unit => "Count", :value => 1)
raise Alephant::Broker::Errors::ContentNotFound
end
def cache_object(component_meta)
cache.get(component_meta.cache_key) do