class ElasticAPM::Spies::SequelSpy
@api private
Constants
- TYPE
Public Class Methods
build_context(sql, opts)
click to toggle source
# File lib/elastic_apm/spies/sequel.rb, line 16 def self.build_context(sql, opts) Span::Context.new( db: { statement: sql, type: 'sql', user: opts[:user] } ) end
summarizer()
click to toggle source
# File lib/elastic_apm/spies/sequel.rb, line 12 def self.summarizer @summarizer ||= SqlSummarizer.new end
Public Instance Methods
install()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/elastic_apm/spies/sequel.rb, line 23 def install require 'sequel/database/logging' ::Sequel::Database.class_eval do alias log_connection_yield_without_apm log_connection_yield def log_connection_yield(sql, *args, &block) unless ElasticAPM.current_transaction return log_connection_yield_without_apm(sql, *args, &block) end summarizer = ElasticAPM::Spies::SequelSpy.summarizer name = summarizer.summarize sql context = ElasticAPM::Spies::SequelSpy.build_context(sql, opts) ElasticAPM.with_span(name, TYPE, context: context, &block) end end end
log_connection_yield(sql, *args, &block)
click to toggle source
# File lib/elastic_apm/spies/sequel.rb, line 29 def log_connection_yield(sql, *args, &block) unless ElasticAPM.current_transaction return log_connection_yield_without_apm(sql, *args, &block) end summarizer = ElasticAPM::Spies::SequelSpy.summarizer name = summarizer.summarize sql context = ElasticAPM::Spies::SequelSpy.build_context(sql, opts) ElasticAPM.with_span(name, TYPE, context: context, &block) end