Class: NewRelic::Agent::SlowSql
- Inherits:
-
Object
- Object
- NewRelic::Agent::SlowSql
- Defined in:
- lib/new_relic/agent/sql_sampler.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#metric_name ⇒ Object
readonly
Returns the value of attribute metric_name.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
Instance Method Summary collapse
- #explain ⇒ Object
-
#initialize(sql, metric_name, config, duration, backtrace = nil, &explainer) ⇒ SlowSql
constructor
A new instance of SlowSql.
- #normalize ⇒ Object
- #obfuscate ⇒ Object
-
#prepare_to_send ⇒ Object
We can’t serialize the explainer, so clear it before we transmit.
Constructor Details
#initialize(sql, metric_name, config, duration, backtrace = nil, &explainer) ⇒ SlowSql
Returns a new instance of SlowSql.
166 167 168 169 170 171 172 173 174 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 166 def initialize(sql, metric_name, config, duration, backtrace=nil, &explainer) @sql = sql @metric_name = metric_name @config = config @duration = duration @backtrace = backtrace @explainer = explainer end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
164 165 166 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 164 def backtrace @backtrace end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
163 164 165 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 163 def duration @duration end |
#metric_name ⇒ Object (readonly)
Returns the value of attribute metric_name.
162 163 164 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 162 def metric_name @metric_name end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
161 162 163 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 161 def sql @sql end |
Instance Method Details
#explain ⇒ Object
185 186 187 188 189 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 185 def explain if @config && @explainer NewRelic::Agent::Database.explain_sql(@sql, @config, &@explainer) end end |
#normalize ⇒ Object
180 181 182 183 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 180 def normalize NewRelic::Agent::Database::Obfuscator.instance \ .default_sql_obfuscator(@sql).gsub(/\?\s*\,\s*/, '').gsub(/\s/, '') end |
#obfuscate ⇒ Object
176 177 178 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 176 def obfuscate NewRelic::Agent::Database.obfuscate_sql(@sql) end |
#prepare_to_send ⇒ Object
We can’t serialize the explainer, so clear it before we transmit
192 193 194 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 192 def prepare_to_send @explainer = nil end |