Module: Aws::Xray::Hooks::ActiveRecord
Constant Summary collapse
- IGNORE_NAMES =
['SCHEMA', 'ActiveRecord::SchemaMigration Load']
Instance Method Summary collapse
-
#record(e) ⇒ Object
event has #name, #time, #end, #duration, #payload payload has #sql, #name, #connection_id, #binds, #cached.
Instance Method Details
#record(e) ⇒ Object
event has #name, #time, #end, #duration, #payload payload has #sql, #name, #connection_id, #binds, #cached
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aws/xray/hooks/active_record.rb', line 16 def record(e) return if IGNORE_NAMES.include?(e.payload[:name]) if !e.payload[:cached] && Aws::Xray::Context.started? pool, con = fetch_connection_and_pool(e.payload[:connection_id]) return if pool.nil? || con.nil? name = build_name(pool.spec) return unless name # skip when connected to default host (typycally localhost) Aws::Xray::Context.current.start_subsegment(name: name, remote: true) do |sub| sub.start(e.time) sub.finish(e.end) sub.set_sql(Aws::Xray::Sql.build( url: build_url(pool.spec), database_version: build_version(con), )) end end end |