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_json(*a) ⇒ 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
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.
182 183 184 185 186 187 188 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 182 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.
179 180 181 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 179 def database_metric_name @database_metric_name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
180 181 182 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 180 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
175 176 177 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 175 def path @path end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
178 179 180 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 178 def sql @sql end |
#sql_id ⇒ Object (readonly)
Returns the value of attribute sql_id.
177 178 179 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 177 def sql_id @sql_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
176 177 178 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 176 def url @url end |
Instance Method Details
#aggregate(slow_sql, path, uri) ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 200 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
217 218 219 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 217 def need_to_explain? Agent.config[:'slow_sql.explain_enabled'] end |
#need_to_obfuscate? ⇒ Boolean
213 214 215 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 213 def need_to_obfuscate? Agent.config[:'slow_sql.record_sql'].to_s == 'obfuscated' end |
#prepare_to_send ⇒ Object
208 209 210 211 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 208 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
190 191 192 193 194 195 196 197 198 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 190 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_json(*a) ⇒ Object
221 222 223 |
# File 'lib/new_relic/agent/sql_sampler.rb', line 221 def to_json(*a) [@path, @url, @sql_id, @sql, @database_metric_name, @call_count, @total_call_time, @min_call_time, @max_call_time, @params].to_json(*a) end |