Class: NewRelic::Agent::SlowSql

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/sql_sampler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql, metric_name, config, duration, backtrace = nil) ⇒ SlowSql

Returns a new instance of SlowSql.



191
192
193
194
195
196
197
# File 'lib/new_relic/agent/sql_sampler.rb', line 191

def initialize(sql, metric_name, config, duration, backtrace = nil)
  @sql = sql
  @metric_name = metric_name
  @config = config
  @duration = duration
  @backtrace = backtrace
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



189
190
191
# File 'lib/new_relic/agent/sql_sampler.rb', line 189

def backtrace
  @backtrace
end

#durationObject (readonly)

Returns the value of attribute duration.



188
189
190
# File 'lib/new_relic/agent/sql_sampler.rb', line 188

def duration
  @duration
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



187
188
189
# File 'lib/new_relic/agent/sql_sampler.rb', line 187

def metric_name
  @metric_name
end

#sqlObject (readonly)

Returns the value of attribute sql.



186
187
188
# File 'lib/new_relic/agent/sql_sampler.rb', line 186

def sql
  @sql
end

Instance Method Details

#explainObject



208
209
210
# File 'lib/new_relic/agent/sql_sampler.rb', line 208

def explain
  NewRelic::Agent::Database.explain_sql(@sql, @config)
end

#normalizeObject



203
204
205
206
# File 'lib/new_relic/agent/sql_sampler.rb', line 203

def normalize
  NewRelic::Agent::Database::Obfuscator.instance \
    .default_sql_obfuscator(@sql).gsub(/\?\s*\,\s*/, '').gsub(/\s/, '')
end

#obfuscateObject



199
200
201
# File 'lib/new_relic/agent/sql_sampler.rb', line 199

def obfuscate
  NewRelic::Agent::Database.obfuscate_sql(@sql)
end