Sha256: 26dba21ab449f2627b9bd25d174a86cbd3a978eaaa16627ef5cdeb35f85cc9b5
Contents?: true
Size: 856 Bytes
Versions: 4
Compression:
Stored size: 856 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(metric_name: 'activejob.perform', **opts) super @metric_name = metric_name 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
4 entries across 4 versions & 1 rubygems