Sha256: 335a277ce27b01410c191b2c2d4da8d2e4c09ae7f0245b213668013be60584e4
Contents?: true
Size: 1.74 KB
Versions: 8
Compression:
Stored size: 1.74 KB
Contents
module Cassanity module Instrumentation class Subscriber # Public: Use this as the subscribed block. def self.call(name, start, ending, transaction_id, payload) new(name, start, ending, transaction_id, payload).update end # Private: Initializes a new event processing instance. def initialize(name, start, ending, transaction_id, payload) @name = name @start = start @ending = ending @payload = payload @duration = ending - start @transaction_id = transaction_id @command_name = @payload[:command] @keyspace_name = @payload[:keyspace_name] @column_family_name = @payload[:column_family_name] end # Public: Actually update all the metriks timers for the event. # # Returns nothing. def update update_timer 'cassanity.cql' if command_name? update_timer "cassanity.command.#{@command_name}.cql" end if column_family_name? update_timer "cassanity.column_family.#{@column_family_name}.cql" end if column_family_name? && command_name? update_timer "cassanity.column_family.#{@column_family_name}.#{@command_name}.cql" end end # Internal: Override in subclass. def update_timer(metric) raise 'not implemented' end # Private: Returns true if command name present else false. def command_name? @command_name_present ||= !@command_name.nil? && !@command_name.empty? end # Private: Returns true if column family name present else false. def column_family_name? @column_family_name_present ||= !@column_family_name.nil? && !@column_family_name.empty? end end end end
Version data entries
8 entries across 8 versions & 1 rubygems