Sha256: 06f74fae4b4942bccf5e24ce5ab4691e30c1cc7650f51f601aabf92d9dc20aa0
Contents?: true
Size: 1.03 KB
Versions: 16
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module Sapience module Extensions module ActiveJob class Notifications < ::Sapience::Extensions::Notifications # Options: # # *<tt>:metric_name</tt> - the metric name, defaults to "activejob.perform" # *<tt>:tags</tt> - additional tags def initialize(opts = {}) super @metric_name = opts[:metric_name] || "activejob.perform" Sapience::Extensions::Notifications.subscribe "perform.active_job" do |event| record event end end private def record(event) # rubocop:disable AbcSize return unless record? job = event.payload[:job] name = job.class.name.sub(/Job$/, "").underscore tags = self.tags + %W(name:#{name} queue:#{job.queue_name}) metrics.batch do metrics.increment metric_name, tags: tags metrics.timing "#{metric_name}.time", event.duration, tags: tags end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems