Sha256: a0c05e56717c484abe83e4cc2d1a4b9f8aee5450df676ef50d70f04d034b20d6
Contents?: true
Size: 1.61 KB
Versions: 26
Compression:
Stored size: 1.61 KB
Contents
module Sapience module Extensions module ActionController class Notifications < ::Sapience::Extensions::Notifications # Options: # # *<tt>:metric_name</tt> - the metric name, defaults to "rails.request" # *<tt>:tags</tt> - additional tags def initialize(options = {}) @metric_name = options[:metric_name] || "rails.request" super Sapience::Extensions::Notifications.subscribe("process_action.action_controller") do |event| record event end end private def record(event) # rubocop:disable AbcSize return unless record? payload = event.payload method = payload[:method].downcase status = payload[:status] action = payload[:action] ctrl = payload[:controller].sub(/Controller$/, "").underscore format = payload[:format] tags = self.tags + %W( method:#{method} status:#{status} action:#{action} controller:#{ctrl} format:#{format} ) metrics.batch do metrics.increment metric_name, tags: tags metrics.timing("#{metric_name}.time", event.duration, tags: tags) if payload[:db_runtime] metrics.timing("#{metric_name}.time.db", payload[:db_runtime].round(10), tags: tags) end if payload[:view_runtime] metrics.timing("#{metric_name}.time.view", payload[:view_runtime].round(2), tags: tags) end end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems