Class: NewRelic::Agent::SqlTrace
- Includes:
- Coerce
- Defined in:
- lib/new_relic/agent/sql_sampler.rb
Instance Attribute Summary collapse
-
#database_metric_name ⇒ Object
readonly
Returns the value of attribute database_metric_name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
-
#sql_id ⇒ Object
readonly
Returns the value of attribute sql_id.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Stats
#call_count, #max_call_time, #min_call_time, #sum_of_squares, #total_call_time, #total_exclusive_time
Instance Method Summary collapse
- #aggregate(slow_sql, path, uri) ⇒ Object
-
#initialize(normalized_query, slow_sql, path, uri) ⇒ SqlTrace
constructor
A new instance of SqlTrace.
- #need_to_explain? ⇒ Boolean
- #need_to_obfuscate? ⇒ Boolean
- #prepare_to_send ⇒ Object
- #set_primary(slow_sql, path, uri) ⇒ Object
- #to_collector_array(encoder) ⇒ Object
Methods included from Coerce
#float, #int, #int_or_nil, #log_failure, #string
Methods inherited from Stats
#==, #increment_count, #inspect, #inspect_full, #is_reset?, #merge, #merge!, #record_apdex, #record_data_point, #record_multiple_data_points, #reset, #to_json, #to_s
Constructor Details
#initialize(normalized_query, slow_sql, path, uri) ⇒ SqlTrace
Returns a new instance of SqlTrace.
205 206 207 208 209 210 211 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 205 def initialize(normalized_query, slow_sql, path, uri) super() @params = {} #FIXME @sql_id = consistent_hash(normalized_query) set_primary slow_sql, path, uri record_data_point(float(slow_sql.duration)) end |
Instance Attribute Details
#database_metric_name ⇒ Object (readonly)
Returns the value of attribute database_metric_name.
202 203 204 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 202 def database_metric_name @database_metric_name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
203 204 205 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 203 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
198 199 200 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 198 def path @path end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
201 202 203 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 201 def sql @sql end |
#sql_id ⇒ Object (readonly)
Returns the value of attribute sql_id.
200 201 202 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 200 def sql_id @sql_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
199 200 201 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 199 def url @url end |
Instance Method Details
#aggregate(slow_sql, path, uri) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 223 def aggregate(slow_sql, path, uri) if slow_sql.duration > max_call_time set_primary slow_sql, path, uri end record_data_point(float(slow_sql.duration)) end |
#need_to_explain? ⇒ Boolean
241 242 243 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 241 def need_to_explain? Agent.config[:'slow_sql.explain_enabled'] end |
#need_to_obfuscate? ⇒ Boolean
237 238 239 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 237 def need_to_obfuscate? Agent.config[:'slow_sql.record_sql'].to_s == 'obfuscated' end |
#prepare_to_send ⇒ Object
231 232 233 234 235 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 231 def prepare_to_send params[:explain_plan] = @slow_sql.explain if need_to_explain? @sql = @slow_sql.obfuscate if need_to_obfuscate? @slow_sql.prepare_to_send end |
#set_primary(slow_sql, path, uri) ⇒ Object
213 214 215 216 217 218 219 220 221 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 213 def set_primary(slow_sql, path, uri) @slow_sql = slow_sql @sql = slow_sql.sql @database_metric_name = slow_sql.metric_name @path = path @url = uri # FIXME @params[:backtrace] = slow_sql.backtrace if slow_sql.backtrace end |
#to_collector_array(encoder) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 247 def to_collector_array(encoder) [ string(@path), string(@url), int(@sql_id), string(@sql), string(@database_metric_name), int(@call_count), Helper.time_to_millis(@total_call_time), Helper.time_to_millis(@min_call_time), Helper.time_to_millis(@max_call_time), encoder.encode(@params) ] end |