Module: Sixty::Instrument::Mysql::Mysql2PreparePatch

Defined in:
lib/sixty/instrument/mysql.rb

Overview

A prepared statement runs its SQL somewhere other than the call site: client.prepare(sql) has the text and statement.execute(id) has the values, and only the second one is a query. Without this, an application using prepared statements reports no database calls at all — the silent blind spot this project refuses, since nothing errors and the feed simply shows a service that never touches its database.

The text is carried on the statement object itself rather than in a map: a statement is a Ruby object with the same lifetime as the prepared statement it stands for, so there is nothing to bound and nothing to evict.

Instance Method Summary collapse

Instance Method Details

#prepare(*args, &block) ⇒ Object



146
147
148
149
150
151
152
153
154
# File 'lib/sixty/instrument/mysql.rb', line 146

def prepare(*args, &block)
  statement = super
  statement.instance_variable_set(:@sixty_sql, args.first)
  statement
rescue StandardError
  # A driver that changed the shape of `prepare` must not take the
  # application's query with it.
  statement
end