Sha256: ccf1c755c8f9f32fb40767273c98ab0ac54b7a41d6c257b6885ddd381ff5f4c3
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module PlainApm module Hooks class ActiveSupportSubscriber def install begin require "active_support/notifications" rescue LoadError return end asn = ::ActiveSupport::Notifications # Rails >= 6.1 if asn.respond_to?(:monotonic_subscribe) asn.monotonic_subscribe(notification_pattern, method(:collect)) else asn.subscribe(notification_pattern, method(:collect)) end end def collect(event) # id / transaction_id is by instrumenter and thread payload = payload(event) return if payload.nil? Agent.instance.collect(payload) end private def pattern raise "Not implemented" end def payload(event) raise "Not implemented" end def common_attributes(event) name, source = *event.name.split(".") bt = filtered_backtrace attrs = { "source" => source, "name" => name, "allocations" => event.allocations, "thread_allocations" => event.thread_allocations, "started_at" => event.time, "finished_at" => event.end } attrs.merge!("backtrace" => bt) if bt && !bt.empty? [name, attrs] end def filtered_backtrace if defined?(Rails) && defined?(Rails::BacktraceCleaner) @cleaner ||= Rails::BacktraceCleaner.new @cleaner.clean(caller) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plain_apm-0.6.7 | lib/plain_apm/hooks/active_support_subscriber.rb |