Sha256: eab9079629e92418e1e5ff0cb2e58377bed7c687af1fb3dc847cd03b8b28a0de
Contents?: true
Size: 855 Bytes
Versions: 3
Compression:
Stored size: 855 Bytes
Contents
module Datadog::Notifications::Plugins class ActiveJob < Base attr_reader :metric_name # 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' Datadog::Notifications.subscribe 'perform.active_job' do |reporter, event| record reporter, event end end private def record(reporter, event) job = event.payload[:job] name = job.class.name.sub(/Job$/, '').underscore tags = self.tags + %W[job:#{name} queue:#{job.queue_name}] reporter.batch do reporter.increment metric_name, tags: tags reporter.timing "#{metric_name}.time", event.duration, tags: tags end end end end
Version data entries
3 entries across 3 versions & 1 rubygems