Class: NewRelic::Agent::SqlTrace
- Inherits:
-
MethodTraceStats
- Object
- StatsBase
- MethodTraceStats
- NewRelic::Agent::SqlTrace
- 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 StatsBase
#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(marshaller) ⇒ Object
Methods inherited from MethodTraceStats
#increment_count, #inspect, #record_data_point, #record_multiple_data_points
Methods inherited from StatsBase
#begin_time, #begin_time=, #end_time, #end_time=, #freeze, #to_json
Methods included from Stats
#absent?, #apdex_score, #as_percentage, #as_percentage_of, #average_call_time, #average_exclusive_time, #calls_per_minute, #checked_calculation, #duration, #exclusive_time_percentage, #expand_min_max_to, #get_apdex, #is_reset?, #merge, #merge!, #merge_attributes, #midpoint, #min_time_less?, #multiply_by, #reset, #should_replace_begin_time?, #should_replace_end_time?, #stack_min_max_from, #standard_deviation, #sum_attributes, #sum_merge!, #summary, #time_percentage, #time_str, #to_s, #total_call_time_per_minute, #update_boundaries, #update_totals
Constructor Details
#initialize(normalized_query, slow_sql, path, uri) ⇒ SqlTrace
Returns a new instance of SqlTrace.
187 188 189 190 191 192 193 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 187 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 slow_sql.duration end |
Instance Attribute Details
#database_metric_name ⇒ Object (readonly)
Returns the value of attribute database_metric_name.
184 185 186 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 184 def database_metric_name @database_metric_name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
185 186 187 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 185 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
180 181 182 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 180 def path @path end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
183 184 185 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 183 def sql @sql end |
#sql_id ⇒ Object (readonly)
Returns the value of attribute sql_id.
182 183 184 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 182 def sql_id @sql_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
181 182 183 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 181 def url @url end |
Instance Method Details
#aggregate(slow_sql, path, uri) ⇒ Object
205 206 207 208 209 210 211 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 205 def aggregate(slow_sql, path, uri) if slow_sql.duration > max_call_time set_primary slow_sql, path, uri end record_data_point slow_sql.duration end |
#need_to_explain? ⇒ Boolean
222 223 224 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 222 def need_to_explain? Agent.config[:'slow_sql.explain_enabled'] end |
#need_to_obfuscate? ⇒ Boolean
218 219 220 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 218 def need_to_obfuscate? Agent.config[:'slow_sql.record_sql'].to_s == 'obfuscated' end |
#prepare_to_send ⇒ Object
213 214 215 216 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 213 def prepare_to_send params[:explain_plan] = @slow_sql.explain if need_to_explain? @sql = @slow_sql.obfuscate if need_to_obfuscate? end |
#set_primary(slow_sql, path, uri) ⇒ Object
195 196 197 198 199 200 201 202 203 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 195 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(marshaller) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 226 def to_collector_array(marshaller) params = if marshaller.respond_to?(:encode_compress) marshaller.encode_compress(@params) else @params end [ @path, @url, @sql_id, @sql, @database_metric_name, @call_count, Helper.time_to_millis(@total_call_time), Helper.time_to_millis(@min_call_time), Helper.time_to_millis(@max_call_time), params ] end |