tingyun_rpm 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -0
  3. data/lib/ting_yun/agent.rb +7 -1
  4. data/lib/ting_yun/agent/collector/error_collector.rb +103 -25
  5. data/lib/ting_yun/agent/collector/error_collector/error_trace_array.rb +2 -0
  6. data/lib/ting_yun/agent/collector/error_collector/noticed_error.rb +20 -13
  7. data/lib/ting_yun/agent/collector/transaction_sampler.rb +4 -1
  8. data/lib/ting_yun/agent/collector/transaction_sampler/class_method.rb +4 -4
  9. data/lib/ting_yun/agent/cross_app/cross_app_tracing.rb +1 -3
  10. data/lib/ting_yun/agent/instance_methods/container_data_manager.rb +6 -0
  11. data/lib/ting_yun/agent/method_tracer_helpers.rb +6 -4
  12. data/lib/ting_yun/agent/transaction.rb +15 -15
  13. data/lib/ting_yun/agent/transaction/apdex.rb +1 -1
  14. data/lib/ting_yun/agent/transaction/class_method.rb +14 -17
  15. data/lib/ting_yun/agent/transaction/exceptions.rb +19 -6
  16. data/lib/ting_yun/agent/transaction/instance_method.rb +8 -4
  17. data/lib/ting_yun/agent/transaction/trace.rb +23 -4
  18. data/lib/ting_yun/agent/transaction/trace_node.rb +26 -6
  19. data/lib/ting_yun/agent/transaction/traced_method_stack.rb +2 -2
  20. data/lib/ting_yun/agent/transaction/transaction_sample_builder.rb +17 -8
  21. data/lib/ting_yun/configuration/default_source.rb +22 -1
  22. data/lib/ting_yun/http/abstract_request.rb +23 -0
  23. data/lib/ting_yun/http/curb_wrappers.rb +76 -0
  24. data/lib/ting_yun/http/excon_wrappers.rb +81 -0
  25. data/lib/ting_yun/http/http_client_request.rb +2 -2
  26. data/lib/ting_yun/http/net_http_request.rb +2 -2
  27. data/lib/ting_yun/http/typhoeus_wrappers.rb +88 -0
  28. data/lib/ting_yun/instrumentation/bunny.rb +3 -3
  29. data/lib/ting_yun/instrumentation/curb.rb +191 -0
  30. data/lib/ting_yun/instrumentation/excon.rb +131 -0
  31. data/lib/ting_yun/instrumentation/grape.rb +4 -2
  32. data/lib/ting_yun/instrumentation/kafka.rb +3 -3
  33. data/lib/ting_yun/instrumentation/memcached.rb +1 -1
  34. data/lib/ting_yun/instrumentation/middleware_proxy.rb +17 -1
  35. data/lib/ting_yun/instrumentation/middleware_tracing.rb +1 -1
  36. data/lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb +1 -0
  37. data/lib/ting_yun/instrumentation/net.rb +24 -24
  38. data/lib/ting_yun/instrumentation/rack.rb +10 -10
  39. data/lib/ting_yun/instrumentation/rails3/action_controller.rb +1 -1
  40. data/lib/ting_yun/instrumentation/rake.rb +8 -4
  41. data/lib/ting_yun/instrumentation/support/action_controller_subscriber.rb +1 -1
  42. data/lib/ting_yun/instrumentation/support/action_view_subscriber.rb +2 -2
  43. data/lib/ting_yun/instrumentation/support/active_record_subscriber.rb +2 -2
  44. data/lib/ting_yun/instrumentation/support/controller_instrumentation.rb +3 -3
  45. data/lib/ting_yun/instrumentation/support/external_error.rb +4 -4
  46. data/lib/ting_yun/instrumentation/support/external_helper.rb +6 -1
  47. data/lib/ting_yun/instrumentation/thrift.rb +1 -1
  48. data/lib/ting_yun/instrumentation/typhoeus.rb +75 -0
  49. data/lib/ting_yun/support/exception.rb +2 -0
  50. data/lib/ting_yun/support/http_clients/uri_util.rb +12 -7
  51. data/lib/ting_yun/ting_yun_service.rb +1 -1
  52. data/lib/ting_yun/ting_yun_service/upload_service.rb +15 -3
  53. data/lib/ting_yun/version.rb +2 -2
  54. metadata +9 -3
  55. data/lib/ting_yun/http/generic_request.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42cfa48ff65b496435593ce17a380b7bff332c65
4
- data.tar.gz: f5afe74bed3f331d60977bebfdf4c51da40c3a47
3
+ metadata.gz: bdc5d84fba459da89f499abfdfce47cf81995046
4
+ data.tar.gz: bade661f66b85afb9e4f5f0ab9c1088424343fb4
5
5
  SHA512:
6
- metadata.gz: ba7ada9279f07888fbacfe7f1ed7334f66143d99138a7395448225f7d98e0ef2cb9db4596c8e84b3cc53ac7567477452dd6a0614b6d40d0460e0c1a55b34cc5a
7
- data.tar.gz: 12c24299ef09a1698720cca513e4b5bdfbd2b7065cec4e1d1e350ce06a69fc4f2adb40b02acca889735933d58b9367fd9046e786369ee3fdf0c4924d62d25e5d
6
+ metadata.gz: a87bbc8cb3dc20381701255dc19773731d73415556861e977c1f483e8d7546ca9cfd9e435bbbf87a14047af5630f962ade76d3c37b55f3306ec1026003b00e6e
7
+ data.tar.gz: 57f728853e98684bd7c6188a29d53367194caea82fcf8a40f1b9896054e7b2e887ae7a17403e1f0275b65dfb4b345074060d50de9cdbd7c6af183ca9d6aa94ec
data/README.md CHANGED
File without changes
@@ -123,11 +123,13 @@ module TingYun
123
123
  #
124
124
  # @api public
125
125
  #
126
- def notice_error(exception, options={})
126
+ def notice_error(exception, options={:type =>:exception})
127
127
  TingYun::Agent::Transaction.notice_error(exception, options)
128
128
  nil # don't return a noticed error datastructure. it can only hurt.
129
129
  end
130
130
 
131
+
132
+
131
133
  # Register this method as a callback for processes that fork
132
134
  # jobs.
133
135
  #
@@ -200,5 +202,9 @@ module TingYun
200
202
  txn.attributes.add_custom_params(key, value) if txn
201
203
  end
202
204
 
205
+ def tl_is_execution_traced?
206
+ TingYun::Agent::TransactionState.tl_get.execution_traced?
207
+ end
208
+
203
209
  end
204
210
  end
@@ -10,12 +10,17 @@ module TingYun
10
10
  module Collector
11
11
  class ErrorCollector
12
12
  ERRORS_ACTION = "Errors/Count/".freeze
13
-
14
-
15
-
16
13
  ERRORS_ALL = "Errors/Count/All".freeze
17
14
  ERRORS_ALL_WEB = "Errors/Count/AllWeb".freeze
18
15
  ERRORS_ALL_BACK_GROUND = "Errors/Count/AllBackground".freeze
16
+ ERRORS_TYPE = "Errors/Type:".freeze
17
+
18
+ EXCEPTIONS_ACTION = "Exception/Count/".freeze
19
+ EXCEPTIONS_ALL = "Exception/Count/All".freeze
20
+ EXCEPTIONS_ALL_WEB = "Exception/Count/AllWeb".freeze
21
+ EXCEPTIONS_ALL_BACK_GROUND = "Exception/Count/AllBackground".freeze
22
+ EXCEPTIONS_TYPE = "Exception/Type:".freeze
23
+
19
24
 
20
25
  # Maximum possible length of the queue - defaults to 20, may be
21
26
  MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
@@ -54,60 +59,131 @@ module TingYun
54
59
  metric_names
55
60
  end
56
61
 
57
- def action_metric_name(txn)
58
- "#{ERRORS_ACTION}#{txn.best_name}" if txn
62
+ def action_metric_names(txn,exception)
63
+ names = ["#{ERRORS_ACTION}#{txn.best_name}"]
64
+ if exception.respond_to? :tingyun_klass
65
+ names << "#{ERRORS_ACTION}#{exception.tingyun_klass}"
66
+ end
67
+ names
68
+ end
69
+
70
+ def aggregated_type_count(exception,txn)
71
+ names = ["#{ERRORS_TYPE}#{exception.class.to_s}/#{txn.best_name}"]
72
+ if exception.respond_to? :tingyun_klass
73
+ names << "#{ERRORS_TYPE}#{exception.tingyun_code}/#{exception.tingyun_klass}"
74
+ end
75
+ names
76
+ end
77
+ def aggregated_exception_metric_names(txn)
78
+ metric_names = [EXCEPTIONS_ALL]
79
+ return metric_names unless txn
80
+
81
+ if TingYun::Agent::Transaction.recording_web_transaction?
82
+ metric_names << EXCEPTIONS_ALL_WEB
83
+ else
84
+ metric_names << EXCEPTIONS_ALL_BACK_GROUND
85
+ end
86
+
87
+ metric_names
88
+ end
89
+ def action_exception_metric_names(txn)
90
+ "#{EXCEPTIONS_ACTION}#{txn.best_name}"
91
+ end
92
+
93
+ def aggregated_exception_type_count(exception,txn)
94
+ if exception.respond_to? :tingyun_klass
95
+ names = ["#{EXCEPTIONS_TYPE}External #{exception.tingyun_code}/#{txn.best_name}"]
96
+ names << "#{ERRORS_TYPE}#{exception.tingyun_code}/#{exception.tingyun_klass}"
97
+ names << "#{ERRORS_ACTION}External/#{exception.tingyun_klass}"
98
+ else
99
+ names = ["#{EXCEPTIONS_TYPE}#{exception.class.to_s}/#{txn.best_name}"]
100
+ end
101
+ names
59
102
  end
60
103
 
61
104
  end
62
105
  include Metric
63
106
 
64
- attr_reader :error_trace_array, :external_error_array
107
+ attr_reader :error_trace_array, :external_error_array,:exception_error_array
65
108
 
66
109
  def initialize
67
110
  @error_trace_array = ::TingYun::Agent::Collector::ErrorTraceArray.new(MAX_ERROR_QUEUE_LENGTH)
68
111
  @external_error_array = ::TingYun::Agent::Collector::ErrorTraceArray.new(MAX_ERROR_QUEUE_LENGTH)
112
+ @exception_error_array = ::TingYun::Agent::Collector::ErrorTraceArray.new(MAX_ERROR_QUEUE_LENGTH)
69
113
  end
70
114
 
71
115
  # See TingYun::Agent.notice_error for options and commentary
72
116
  def notice_error(exception, options={})
73
117
  tag_exception(exception)
74
118
  state = ::TingYun::Agent::TransactionState.tl_get
75
- increment_error_count(state)
76
- noticed_error = create_noticed_error(exception, options)
119
+ increment_error_count(exception,state,options[:type])
120
+ _error = create_noticed_error(exception, options)
121
+ noticed_error = _error.clone
77
122
  if noticed_error.is_external_error
78
- external_error_array.add_to_error_queue(noticed_error)
123
+ noticed_error.is_external_error = nil
124
+ external_error_array.add_to_error_queue(_error)
125
+ end
126
+ if noticed_error.type && noticed_error.type == :exception
127
+ exception_error_array.add_to_error_queue(noticed_error)
79
128
  else
80
129
  error_trace_array.add_to_error_queue(noticed_error)
81
130
  end
131
+
132
+
82
133
  rescue => e
83
134
  ::TingYun::Agent.logger.warn("Failure when capturing error '#{exception}':", e)
84
135
  nil
85
136
  end
86
137
 
87
138
  # Increments a statistic that tracks total error rate
88
- def increment_error_count(state)
89
- txn = state.current_transaction
90
-
91
- metric_names = aggregated_metric_names(txn)
92
-
93
- action_metric = action_metric_name(txn)
94
- metric_names << action_metric if action_metric
95
139
 
96
- stats_engine = TingYun::Agent.agent.stats_engine
97
- stats_engine.record_unscoped_metrics(state, metric_names) do |stats|
98
- stats.increment_count
140
+ # Notice the error with the given available options:
141
+ #
142
+ # * <tt>:type</tt> => default nil; :exception,:error
143
+ #
144
+ def increment_error_count(exception,state, type)
145
+ txn = state.current_transaction
146
+ if type && type==:exception
147
+ exception_metric_names = aggregated_exception_metric_names(txn)
148
+ exception_metric_names.concat aggregated_exception_type_count(exception,txn)
149
+ exception_metric_names << action_exception_metric_names(txn)
150
+ stats_engine = TingYun::Agent.agent.stats_engine
151
+ stats_engine.record_unscoped_metrics(state, exception_metric_names) do |stats|
152
+ stats.increment_count
153
+ end
154
+ else
155
+ metric_names = aggregated_metric_names(txn)
156
+ metric_names.concat aggregated_type_count(exception,txn)
157
+ metric_names.concat action_metric_names(txn,exception)
158
+ stats_engine = TingYun::Agent.agent.stats_engine
159
+ stats_engine.record_unscoped_metrics(state, metric_names) do |stats|
160
+ stats.increment_count
161
+ end
99
162
  end
100
163
  end
101
164
 
102
165
  EMPTY_STRING = ''.freeze
103
166
 
104
167
  def create_noticed_error(exception, options)
105
- attributes = options[:attributes]
106
- error_metric = attributes.agent_attributes[:metric_name] || EMPTY_STRING
107
- noticed_error = TingYun::Agent::Collector::NoticedError.new(error_metric, exception)
108
- noticed_error.attributes = attributes
109
- noticed_error.stack_trace = extract_stack_trace(exception)
110
- noticed_error
168
+ if options[:type] && options[:type]==:exception
169
+ attributes = options[:attributes]
170
+ error_metric = options[:attributes].agent_attributes[:metric_name] || EMPTY_STRING
171
+ noticed_error = TingYun::Agent::Collector::NoticedError.new(error_metric, exception)
172
+ noticed_error.attributes = attributes
173
+ noticed_error.stack_trace = extract_stack_trace(exception) if ::TingYun::Agent.config[:'nbs.exception.stack_enabled']
174
+ noticed_error.type = options[:type]
175
+ noticed_error
176
+ else
177
+ attributes = options[:attributes]
178
+ error_metric = attributes.agent_attributes[:metric_name] || EMPTY_STRING
179
+ noticed_error = TingYun::Agent::Collector::NoticedError.new(error_metric, exception)
180
+ noticed_error.attributes = attributes
181
+ noticed_error.stack_trace = extract_stack_trace(exception)
182
+ noticed_error.type = options[:type]
183
+ noticed_error.code = attributes.agent_attributes[:httpStatus]
184
+ noticed_error
185
+ end
186
+
111
187
  end
112
188
 
113
189
 
@@ -146,6 +222,8 @@ module TingYun
146
222
  @external_error_array.reset!
147
223
  nil
148
224
  end
225
+
226
+
149
227
  end
150
228
  end
151
229
  end
@@ -12,6 +12,8 @@ module TingYun
12
12
  @errors = []
13
13
  end
14
14
 
15
+
16
+
15
17
  def enabled?
16
18
  ::TingYun::Agent.config[:'nbs.error_collector.enabled']
17
19
  end
@@ -16,7 +16,7 @@ module TingYun
16
16
 
17
17
  attr_accessor :metric_name, :timestamp, :message, :exception_class_name,
18
18
  :stack_trace, :attributes_from_notice_error, :attributes,
19
- :count_error, :is_external_error, :external_metric_name, :code, :trace
19
+ :count_error, :is_external_error, :external_metric_name, :code, :trace, :type, :http_code
20
20
 
21
21
  attr_reader :exception_id, :is_internal
22
22
 
@@ -27,11 +27,12 @@ module TingYun
27
27
  @stack_trace = []
28
28
  @count_error = 1
29
29
  @exception_id = exception.object_id
30
- @exception_class_name = exception.is_a?(Exception) ? exception.class.name : 'Error'
30
+ @exception_class_name = exception.is_a?(Exception)? exteneral_error?(exception)? "External #{exception.tingyun_code}" : exception.class.name : 'Error'
31
31
  @is_external_error = exception.respond_to?(:tingyun_external)? exception.tingyun_external : false
32
+ @code = 0
32
33
  if @is_external_error
33
34
  @external_metric_name = exception.tingyun_klass
34
- @code = exception.tingyun_code
35
+ @http_code = exception.tingyun_code
35
36
  @trace = exception.tingyun_trace
36
37
  end
37
38
  # It's critical that we not hold onto the exception class constant in this
@@ -80,7 +81,7 @@ module TingYun
80
81
  if is_external_error
81
82
  [timestamp.to_i,
82
83
  string(external_metric_name),
83
- int(code),
84
+ int(http_code),
84
85
  string(exception_class_name),
85
86
  count_error,
86
87
  string(metric_name),
@@ -89,12 +90,13 @@ module TingYun
89
90
  else
90
91
  [timestamp.to_i,
91
92
  string(metric_name),
92
- int(attributes.agent_attributes[:httpStatus]),
93
+ int(code),
93
94
  string(exception_class_name),
94
95
  string(message),
95
96
  count_error,
96
97
  string(attributes.agent_attributes[:request_path]||metric_name),
97
- encoder.encode(error_params)
98
+ encoder.encode(error_params),
99
+ attributes.agent_attributes[:trace_id]
98
100
  ]
99
101
  end
100
102
  end
@@ -104,7 +106,7 @@ module TingYun
104
106
  :params => custom_params
105
107
  }
106
108
  if is_external_error
107
- hash[:stacktrace] = trace
109
+ hash[:stacktrace] = trace
108
110
  else
109
111
  hash[:stacktrace] = stack_trace
110
112
  hash[:requestParams] = request_params
@@ -113,13 +115,10 @@ module TingYun
113
115
  end
114
116
 
115
117
  def custom_params
118
+ return {} if type ==:exception
116
119
  hash = {:threadName => string(attributes.agent_attributes[:threadName])}
117
- if is_external_error
118
- hash[:httpStatus] = int(code)
119
- else
120
- hash[:httpStatus] = int(attributes.agent_attributes[:httpStatus])
121
- hash[:referer] = string(attributes.agent_attributes[:referer]) || ''
122
- end
120
+ hash[:httpStatus] = int(code)
121
+ hash[:referer] = string(attributes.agent_attributes[:referer]) || ''
123
122
  hash
124
123
  end
125
124
 
@@ -128,6 +127,14 @@ module TingYun
128
127
  attributes.request_params
129
128
  end
130
129
 
130
+ def exteneral_error? exception
131
+ if defined? ::Thrift::ApplicationException
132
+ exception.is_a?(TingYun::Support::Exception::InternalServerError) or exception.is_a?(::Thrift::ApplicationException)
133
+ else
134
+ exception.is_a?(TingYun::Support::Exception::InternalServerError)
135
+ end
136
+ end
137
+
131
138
  end
132
139
  end
133
140
  end
@@ -62,7 +62,8 @@ module TingYun
62
62
  end
63
63
  end
64
64
 
65
- def on_finishing_transaction(state, txn, time=Time.now.to_f)
65
+ def on_finishing_transaction(state, txn, time=Time.now.to_f, exceptions)
66
+
66
67
  last_builder = state.transaction_sample_builder
67
68
  return unless last_builder && TingYun::Agent.config[:'nbs.action_tracer.enabled']
68
69
 
@@ -70,6 +71,8 @@ module TingYun
70
71
 
71
72
  final_trace = last_builder.trace
72
73
  final_trace.attributes = txn.attributes
74
+ final_trace.array_size = exceptions.errors_and_exceptions
75
+ final_trace.add_errors(exceptions.errors.keys)
73
76
 
74
77
 
75
78
  @lock.synchronize do
@@ -7,17 +7,17 @@ module TingYun
7
7
  module ClassMethod
8
8
 
9
9
 
10
- def notice_push_frame(state, time=Time.now)
10
+ def notice_push_frame(state, time=Time.now.to_f)
11
11
  builder = state.transaction_sample_builder
12
12
  return unless builder
13
- builder.trace_entry(time.to_f)
13
+ builder.trace_entry(time)
14
14
  end
15
15
 
16
16
  # Informs the transaction sample builder about the end of a traced frame
17
- def notice_pop_frame(state, frame, time = Time.now, klass_name=nil)
17
+ def notice_pop_frame(state, frame, time = Time.now.to_f, klass_name=nil, error = nil)
18
18
  builder = state.transaction_sample_builder
19
19
  return unless builder
20
- builder.trace_exit(frame, time.to_f, klass_name)
20
+ builder.trace_exit(frame, time, klass_name, error)
21
21
  end
22
22
 
23
23
 
@@ -36,9 +36,6 @@ module TingYun
36
36
  node = start_trace(state, t0, request)
37
37
  response = yield
38
38
  capture_exception(response, request)
39
- rescue => e
40
- klass = "External/#{request.uri.to_s.gsub(/\/\z/,'').gsub('/','%2F')}/#{request.from}"
41
- handle_error(e, klass)
42
39
  ensure
43
40
  finish_trace(state, t0, node, request, response)
44
41
  end
@@ -54,6 +51,7 @@ module TingYun
54
51
  end
55
52
 
56
53
  def finish_trace(state, t0, node, request, response)
54
+
57
55
  t1 = Time.now.to_f
58
56
  duration = (t1- t0) * 1000
59
57
  state.timings.external_duration = duration
@@ -51,6 +51,7 @@ module TingYun
51
51
  @service.session do # use http keep-alive
52
52
  harvest_and_send_errors
53
53
  harvest_and_send_external_errors
54
+ harvest_and_send_exceptions
54
55
  harvest_and_send_timeslice_data
55
56
  harvest_and_send_transaction_traces
56
57
  harvest_and_send_slowest_sql
@@ -65,6 +66,11 @@ module TingYun
65
66
  harvest_and_send_from_container(@error_collector.error_trace_array, :error_data)
66
67
  end
67
68
 
69
+ def harvest_and_send_exceptions
70
+ harvest_and_send_from_container(@error_collector.exception_error_array, :exception_data)
71
+ end
72
+
73
+
68
74
  def harvest_and_send_external_errors
69
75
  harvest_and_send_from_container(@error_collector.external_error_array, :external_error_data)
70
76
  end
@@ -13,7 +13,6 @@ module TingYun
13
13
  yield
14
14
  rescue => e
15
15
  ::TingYun::Agent.logger.error("Caught exception in #{code_area}.", e)
16
- ::TingYun::Agent.notice_error(e, method: code_area, path: "ting_yun/agent/method_tracer_helpers")
17
16
  end
18
17
 
19
18
  def trace_execution_scoped_header(state, t0)
@@ -23,12 +22,12 @@ module TingYun
23
22
  end
24
23
  end
25
24
 
26
- def trace_execution_scoped_footer(state, t0, first_name, metric_names, expected_frame, options, t1=Time.now.to_f, klass_name=nil)
25
+ def trace_execution_scoped_footer(state, t0, first_name, metric_names, expected_frame, options, t1=Time.now.to_f, klass_name=nil, error = nil)
27
26
  log_errors(:trace_execution_scoped_footer) do
28
27
  if expected_frame
29
28
  stack = state.traced_method_stack
30
29
  create_metrics = options.has_key?(:metric) ? options[:metric] : true
31
- frame = stack.pop_frame(state, expected_frame, first_name, t1, create_metrics, klass_name)
30
+ frame = stack.pop_frame(state, expected_frame, first_name, t1, create_metrics, klass_name, error)
32
31
 
33
32
  if create_metrics
34
33
  duration = (t1 - t0)*1000
@@ -73,12 +72,15 @@ module TingYun
73
72
 
74
73
  begin
75
74
  yield
75
+ rescue => e
76
+ TingYun::Agent.notice_error(e,:type=>:exception)
77
+ raise e
76
78
  ensure
77
79
  elapsed_time = (Time.now.to_f - start_time)
78
80
  if callback
79
81
  callback.call(elapsed_time)
80
82
  end
81
- trace_execution_scoped_footer(state, start_time, first_name, metric_names, expected_scope, options, Time.now.to_f, klass_name)
83
+ trace_execution_scoped_footer(state, start_time, first_name, metric_names, expected_scope, options, Time.now.to_f, klass_name,e)
82
84
  end
83
85
  end
84
86
 
@@ -31,7 +31,7 @@ module TingYun
31
31
  TASK_PREFIX = 'OtherTransaction/Background/'.freeze
32
32
  RACK_PREFIX = 'Rack/'.freeze
33
33
  SINATRA_PREFIX = 'WebAction/Sinatra/'.freeze
34
- MIDDLEWARE_PREFIX = 'Middleware/Rack/'.freeze
34
+ MIDDLEWARE_PREFIX = 'Middleware/'.freeze
35
35
  GRAPE_PREFIX = 'WebAction/Grape/'.freeze
36
36
  RAKE_PREFIX = 'WebAction/Rake'.freeze
37
37
  CABLE_PREFIX = 'WebAction/ActionCable'.freeze
@@ -66,7 +66,7 @@ module TingYun
66
66
 
67
67
 
68
68
  def initialize(category, client_transaction_id, options)
69
- @start_time = Time.now
69
+ @start_time = Time.now.to_f
70
70
 
71
71
  @exceptions = TingYun::Agent::Transaction::Exceptions.new
72
72
  @metrics = TingYun::Agent::TransactionMetrics.new
@@ -129,21 +129,21 @@ module TingYun
129
129
  trace_options = TRACE_OPTIONS_UNSCOPED
130
130
  end
131
131
 
132
- if name.start_with?(MIDDLEWARE_PREFIX)
133
- summary_metrics_with_exclusive_time = MIDDLEWARE_SUMMARY_METRICS
134
- else
135
- summary_metrics_with_exclusive_time = EMPTY_SUMMARY_METRICS
136
- end
137
- summary_metrics_with_exclusive_time = summary_metrics unless summary_metrics.empty?
132
+ # if name.start_with?(MIDDLEWARE_PREFIX)
133
+ # summary_metrics_with_exclusive_time = MIDDLEWARE_SUMMARY_METRICS
134
+ # else
135
+ # summary_metrics_with_exclusive_time = EMPTY_SUMMARY_METRICS
136
+ # end
137
+ # summary_metrics_with_exclusive_time = summary_metrics unless summary_metrics.empty?
138
138
 
139
139
  TingYun::Agent::MethodTracerHelpers.trace_execution_scoped_footer(
140
140
  state,
141
- start_time.to_f,
141
+ start_time,
142
142
  name,
143
- summary_metrics_with_exclusive_time,
143
+ EMPTY_SUMMARY_METRICS,
144
144
  outermost_frame,
145
145
  trace_options,
146
- end_time.to_f)
146
+ end_time)
147
147
 
148
148
  commit(state, end_time, name)
149
149
  end
@@ -151,20 +151,20 @@ module TingYun
151
151
 
152
152
  def commit(state, end_time, outermost_node_name)
153
153
 
154
- assign_agent_attributes
154
+ assign_agent_attributes(state)
155
155
 
156
156
 
157
- TingYun::Agent.instance.transaction_sampler.on_finishing_transaction(state, self, end_time)
157
+ TingYun::Agent.instance.transaction_sampler.on_finishing_transaction(state, self, end_time,@exceptions)
158
158
 
159
159
  TingYun::Agent.instance.sql_sampler.on_finishing_transaction(state, @frozen_name)
160
160
 
161
- record_summary_metrics(state, outermost_node_name, end_time)
161
+ record_summary_metrics(state, outermost_node_name, end_time) unless @exceptions.had_error?
162
162
  @apdex.record_apdex(@frozen_name, end_time, @exceptions.had_error?)
163
163
  @exceptions.record_exceptions(@attributes)
164
164
 
165
165
 
166
166
  TingYun::Agent.instance.stats_engine.merge_transaction_metrics!(@metrics, best_name)
167
- TingYun::Agent.instance.stats_engine.record_base_quantile(@base_quantile_hash) if @exceptions.exceptions.empty?
167
+ TingYun::Agent.instance.stats_engine.record_base_quantile(@base_quantile_hash) unless @exceptions.had_error?
168
168
  end
169
169
 
170
170
  end