lib/dogstatsd/instrumentation/request.rb in dogstatsd-instrumentation-0.1.2 vs lib/dogstatsd/instrumentation/request.rb in dogstatsd-instrumentation-0.1.3

- old
+ new

@@ -20,11 +20,11 @@ end # From GemConfig::Base def self.configure super - @@subscriber.unsubscribe if @@subscriber + @@subscriber = @@subscriber.unsubscribe if @@subscriber @@subscriber = Subscriber.new(configuration) if configuration.enabled end @@subscriber = nil @@ -41,15 +41,16 @@ @subscriber = ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args| event = ActiveSupport::Notifications::Event.new(*args) tags = { controller: event.payload[:controller], - action: event.payload[:action], method: event.payload[:method], status: event.payload[:status], } + tags[:action] = "#{tags[:controller]}##{event.payload[:action]}" if event.payload[:action] + instrument stat: 'process_action.action_controller.duration', value: event.duration, tags: tags event.payload.select { |key, _| key.to_s.end_with? '_runtime' }.each do |name, duration| instrument stat: "process_action.action_controller.#{name}", value: duration, tags: tags end @@ -59,15 +60,16 @@ def instrument(stat:, value:, tags:) @statsd.histogram stat, value, tags: Subscriber.tagify(@base_tags.merge(tags)) end def self.tagify(hash) - hash.select{|_,value| value.present? }.map { |key, value| "#{key}:#{value}" } + hash.select { |_, value| value.present? }.map { |key, value| "#{key}:#{value}" } end def unsubscribe ActiveSupport::Notifications.unsubscribe @subscriber + nil end end end end -end \ No newline at end of file +end