Method: ScoutRailsProxy::Instruments::ActiveRecordInstruments#scout_sanitize_sql
- Defined in:
- lib/scout_rails_proxy/instruments/active_record_instruments.rb
#scout_sanitize_sql(sql) ⇒ Object
Removes actual values from SQL. Used to both obfuscate the SQL and group similar queries in the UI.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/scout_rails_proxy/instruments/active_record_instruments.rb', line 47 def scout_sanitize_sql(sql) return nil if sql.length > 1000 # safeguard - don't sanitize large SQL statements sql = sql.dup sql.gsub!(/\\"/, '') # removing escaping double quotes sql.gsub!(/\\'/, '') # removing escaping single quotes sql.gsub!(/'(?:[^']|'')*'/, '?') # removing strings (single quote) sql.gsub!(/"(?:[^"]|"")*"/, '?') # removing strings (double quote) sql.gsub!(/\b\d+\b/, '?') # removing integers sql.gsub!(/\?(,\?)+/,'?') # replace multiple ? w/a single ? sql end |