Sha256: d558d33054fdc75654c533f894fabccc0dac5a987fd291f6f24c1f322856543a
Contents?: true
Size: 1.67 KB
Versions: 4
Compression:
Stored size: 1.67 KB
Contents
require 'agent/am_objectholder' require 'agent/trackers/database_tracker' module ManageEngine module Instrumentation class ActiveRecordSQL def present? defined?(::ActiveRecord::Base) && defined?(::ActiveSupport::Notifications) end def name 'ActiveRecord' end def instrument @obj = ManageEngine::APMObjectHolder.instance @obj.log.info "Instrumenting ActiveRecord" ActiveSupport::Notifications.subscribe('sql.active_record') do |name, start, finish, id, payload| begin if @obj.config.agent_enabled && @obj.config.sql_capture && payload[:name] != "SCHEMA" # Dropping internal schema related queries tracker = Thread.current[:apminsight] if tracker != nil dbTracker = ManageEngine::Tracker::DatabaseTracker.new(payload[:name], start.to_f * 1000) dbTracker.sql(payload[:sql]) dbTracker.params(payload[:binds]) dbTracker.finish(finish.to_f * 1000) if dbTracker.duration >= @obj.config.sql_trace_t.to_f dbTracker.sqlBacktrace(caller(10)) end exception = payload[:exception_object] if exception != nil dbTracker.setError(exception) end tracker.addChild(dbTracker) end end rescue Exception => e @obj.log.logException("Error processing #{name} payload", e) end end #subscribe end #def instrument end #class ActiveRecordSQL end end
Version data entries
4 entries across 4 versions & 1 rubygems