class StackifyRubyAPM::Spies::SqliteAdapterSpy
@api private
Constants
- TYPE
Public Instance Methods
check_prepared_stmt(statement, payload)
click to toggle source
# File lib/stackify_apm/spies/sinatra_activerecord/sqlite_adapter.rb, line 47 def check_prepared_stmt(statement, payload) if StackifyRubyAPM.agent.config.prefix_enabled check_prepared_stmt_by_placeholder(payload[:sql].include?('?'), statement, payload) end end
exec_query(sql, name = 'SQL', binds = [], prepare: false)
click to toggle source
rubocop:disable Lint/UnusedMethodArgument
# File lib/stackify_apm/spies/sinatra_activerecord/sqlite_adapter.rb, line 21 def exec_query(sql, name = 'SQL', binds = [], prepare: false) result = nil unless StackifyRubyAPM.current_transaction exec_query_without_apm(sql, name, binds) end payload = {sql: sql, binds: binds} statement = query_variables(payload) check_prepared_stmt(statement, payload) ctx = Span::Context.new(statement) result = exec_query_without_apm(sql, name, binds) StackifyRubyAPM.span name, TYPE, context: ctx do return result end end
install()
click to toggle source
# File lib/stackify_apm/spies/sinatra_activerecord/sqlite_adapter.rb, line 16 def install ActiveRecord::ConnectionAdapters::SQLite3Adapter.class_eval do alias_method 'exec_query_without_apm', 'exec_query' # rubocop:disable Lint/UnusedMethodArgument def exec_query(sql, name = 'SQL', binds = [], prepare: false) result = nil unless StackifyRubyAPM.current_transaction exec_query_without_apm(sql, name, binds) end payload = {sql: sql, binds: binds} statement = query_variables(payload) check_prepared_stmt(statement, payload) ctx = Span::Context.new(statement) result = exec_query_without_apm(sql, name, binds) StackifyRubyAPM.span name, TYPE, context: ctx do return result end end # rubocop:enable Lint/UnusedMethodArgument def query_variables(payload) props = get_common_db_properties props[:SQL] = payload[:sql] props end def check_prepared_stmt(statement, payload) if StackifyRubyAPM.agent.config.prefix_enabled check_prepared_stmt_by_placeholder(payload[:sql].include?('?'), statement, payload) end end end end
query_variables(payload)
click to toggle source
rubocop:enable Lint/UnusedMethodArgument
# File lib/stackify_apm/spies/sinatra_activerecord/sqlite_adapter.rb, line 41 def query_variables(payload) props = get_common_db_properties props[:SQL] = payload[:sql] props end