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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of SlowSql.



14
15
16
17
18
19
20
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 14

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

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



10
11
12
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 10

def backtrace
  @backtrace
end

#durationObject (readonly)

Returns the value of attribute duration.



9
10
11
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 9

def duration
  @duration
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



8
9
10
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 8

def metric_name
  @metric_name
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



11
12
13
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 11

def start_time
  @start_time
end

#statementObject (readonly)

Returns the value of attribute statement.



7
8
9
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 7

def statement
  @statement
end

Instance Method Details

#explainObject



35
36
37
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 35

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

#normalizeObject



31
32
33
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 31

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

#obfuscateObject



26
27
28
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 26

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

#prepare_to_sendObject

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



40
41
42
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 40

def prepare_to_send
  statement.explainer = nil
end

#sqlObject



22
23
24
# File 'lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb', line 22

def sql
  statement.sql
end