Class: TingYun::Agent::Collector::SlowSql

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statement, metric_name, duration, t0, backtrace = nil) ⇒ SlowSql

Returns a new instance of SlowSql.



199
200
201
202
203
204
205
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 199

def initialize(statement, metric_name, duration, t0,  backtrace=nil)
  @start_time = t0
  @statement = statement
  @metric_name = metric_name
  @duration = duration
  @backtrace = backtrace
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



195
196
197
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 195

def backtrace
  @backtrace
end

#durationObject (readonly)

Returns the value of attribute duration.



194
195
196
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 194

def duration
  @duration
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



193
194
195
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 193

def metric_name
  @metric_name
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



196
197
198
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 196

def start_time
  @start_time
end

#statementObject (readonly)

Returns the value of attribute statement.



192
193
194
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 192

def statement
  @statement
end

Instance Method Details

#explainObject



220
221
222
223
224
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 220

def explain
  if statement.config && statement.explainer
    TingYun::Agent::Database.explain_sql(statement.sql, statement.config, statement.explainer)
  end
end

#normalizeObject



216
217
218
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 216

def normalize
  TingYun::Agent::Database::Obfuscator.instance.default_sql_obfuscator(statement)
end

#obfuscateObject



211
212
213
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 211

def obfuscate
  TingYun::Agent::Database.obfuscate_sql(statement)
end

#prepare_to_sendObject

We can’t serialize the explainer, so clear it before we transmit



227
228
229
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 227

def prepare_to_send
  statement.explainer = nil
end

#sqlObject



207
208
209
# File 'lib/ting_yun/agent/collector/sql_sampler.rb', line 207

def sql
  statement.sql
end