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.



157
158
159
160
161
162
163
# File 'lib/new_relic/agent/sql_sampler.rb', line 157

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.



155
156
157
# File 'lib/new_relic/agent/sql_sampler.rb', line 155

def backtrace
  @backtrace
end

#durationObject (readonly)

Returns the value of attribute duration.



154
155
156
# File 'lib/new_relic/agent/sql_sampler.rb', line 154

def duration
  @duration
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



153
154
155
# File 'lib/new_relic/agent/sql_sampler.rb', line 153

def metric_name
  @metric_name
end

#sqlObject (readonly)

Returns the value of attribute sql.



152
153
154
# File 'lib/new_relic/agent/sql_sampler.rb', line 152

def sql
  @sql
end

Instance Method Details

#explainObject



174
175
176
# File 'lib/new_relic/agent/sql_sampler.rb', line 174

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

#normalizeObject



169
170
171
172
# File 'lib/new_relic/agent/sql_sampler.rb', line 169

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

#obfuscateObject



165
166
167
# File 'lib/new_relic/agent/sql_sampler.rb', line 165

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