Sha256: 90835bc17a8a2b815ec1af7a86988eaf1acaf0dc772034d84b383244ef1fb341
Contents?: true
Size: 841 Bytes
Versions: 20
Compression:
Stored size: 841 Bytes
Contents
class CC::Service::Invocation class WithMetrics def initialize(invocation, statsd, prefix = nil) @invocation = invocation @statsd = statsd @prefix = prefix end def call start_time = Time.now result = @invocation.call @statsd.increment(success_key) result rescue => ex @statsd.increment(error_key(ex)) raise ex ensure duration = ((Time.now - start_time) * 1_000).round @statsd.timing(timing_key, duration) end def success_key ["services.invocations", @prefix].compact.join('.') end def timing_key ["services.timing", @prefix].compact.join('.') end def error_key(ex) error_string = ex.class.name.underscore.gsub("/", "-") ["services.errors", @prefix, error_string].compact.join('.') end end end
Version data entries
20 entries across 20 versions & 1 rubygems