dolores_rpm 3.2.0.6 → 3.3.4.fork

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/CHANGELOG +32 -6
  2. data/dolores_rpm.gemspec +15 -11
  3. data/lib/new_relic/agent/agent.rb +28 -14
  4. data/lib/new_relic/agent/beacon_configuration.rb +11 -0
  5. data/lib/new_relic/agent/browser_monitoring.rb +53 -13
  6. data/lib/new_relic/agent/database.rb +34 -14
  7. data/lib/new_relic/agent/error_collector.rb +1 -1
  8. data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -1
  9. data/lib/new_relic/agent/instrumentation/active_record.rb +137 -0
  10. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +24 -5
  11. data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -36
  12. data/lib/new_relic/agent/instrumentation/metric_frame.rb +24 -3
  13. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +3 -2
  14. data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
  15. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +88 -30
  16. data/lib/new_relic/agent/instrumentation/sinatra.rb +40 -20
  17. data/lib/new_relic/agent/samplers/memory_sampler.rb +5 -6
  18. data/lib/new_relic/agent/sql_sampler.rb +35 -16
  19. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
  20. data/lib/new_relic/agent/stats_engine/samplers.rb +1 -1
  21. data/lib/new_relic/agent/stats_engine/transactions.rb +2 -85
  22. data/lib/new_relic/agent/stats_engine.rb +1 -0
  23. data/lib/new_relic/agent/transaction_info.rb +74 -0
  24. data/lib/new_relic/agent/transaction_sample_builder.rb +17 -3
  25. data/lib/new_relic/agent/transaction_sampler.rb +86 -15
  26. data/lib/new_relic/agent/worker_loop.rb +1 -1
  27. data/lib/new_relic/agent.rb +15 -2
  28. data/lib/new_relic/collection_helper.rb +8 -6
  29. data/lib/new_relic/command.rb +1 -1
  30. data/lib/new_relic/commands/deployments.rb +1 -1
  31. data/lib/new_relic/control/configuration.rb +6 -2
  32. data/lib/new_relic/control/frameworks/merb.rb +1 -1
  33. data/lib/new_relic/control/frameworks/rails.rb +5 -5
  34. data/lib/new_relic/control/frameworks/rails3.rb +2 -2
  35. data/lib/new_relic/control/instance_methods.rb +3 -3
  36. data/lib/new_relic/control/instrumentation.rb +1 -1
  37. data/lib/new_relic/control/server_methods.rb +2 -2
  38. data/lib/new_relic/data_serialization.rb +10 -16
  39. data/lib/new_relic/delayed_job_injection.rb +6 -1
  40. data/lib/new_relic/language_support.rb +11 -7
  41. data/lib/new_relic/local_environment.rb +24 -10
  42. data/lib/new_relic/metric_spec.rb +7 -6
  43. data/lib/new_relic/noticed_error.rb +6 -1
  44. data/lib/new_relic/rack/browser_monitoring.rb +21 -13
  45. data/lib/new_relic/rack/developer_mode.rb +2 -2
  46. data/lib/new_relic/recipes.rb +8 -4
  47. data/lib/new_relic/stats.rb +0 -53
  48. data/lib/new_relic/transaction_sample/segment.rb +2 -0
  49. data/lib/new_relic/transaction_sample.rb +39 -23
  50. data/lib/new_relic/version.rb +3 -3
  51. data/test/active_record_fixtures.rb +3 -3
  52. data/test/fixtures/proc_cpuinfo.txt +575 -0
  53. data/test/new_relic/agent/agent/connect_test.rb +4 -11
  54. data/test/new_relic/agent/agent_test.rb +1 -0
  55. data/test/new_relic/agent/agent_test_controller_test.rb +20 -1
  56. data/test/new_relic/agent/beacon_configuration_test.rb +10 -7
  57. data/test/new_relic/agent/browser_monitoring_test.rb +90 -45
  58. data/test/new_relic/agent/database_test.rb +34 -47
  59. data/test/new_relic/agent/error_collector_test.rb +32 -15
  60. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +56 -18
  61. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +0 -2
  62. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -1
  63. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +3 -3
  64. data/test/new_relic/agent/instrumentation/queue_time_test.rb +6 -11
  65. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -1
  66. data/test/new_relic/agent/method_tracer_test.rb +2 -2
  67. data/test/new_relic/agent/rpm_agent_test.rb +1 -1
  68. data/test/new_relic/agent/sql_sampler_test.rb +48 -16
  69. data/test/new_relic/agent/stats_engine_test.rb +41 -6
  70. data/test/new_relic/agent/transaction_info_test.rb +13 -0
  71. data/test/new_relic/agent/transaction_sample_builder_test.rb +19 -3
  72. data/test/new_relic/agent/transaction_sampler_test.rb +49 -37
  73. data/test/new_relic/agent/worker_loop_test.rb +1 -1
  74. data/test/new_relic/agent_test.rb +12 -0
  75. data/test/new_relic/control/configuration_test.rb +12 -0
  76. data/test/new_relic/control_test.rb +2 -0
  77. data/test/new_relic/data_serialization_test.rb +12 -12
  78. data/test/new_relic/local_environment_test.rb +14 -1
  79. data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
  80. data/test/new_relic/rack/browser_monitoring_test.rb +81 -23
  81. data/test/new_relic/rack/developer_mode_test.rb +31 -0
  82. data/test/new_relic/stats_test.rb +0 -15
  83. data/test/new_relic/transaction_sample_test.rb +13 -0
  84. data/test/script/build_test_gem.sh +51 -0
  85. data/test/script/ci.sh +94 -0
  86. data/test/script/ci_bench.sh +52 -0
  87. data/test/test_helper.rb +1 -0
  88. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +5 -0
  89. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +17 -4
  90. metadata +25 -19
  91. data/dolores_rpm-3.2.0.2.gem +0 -0
  92. data/dolores_rpm-3.2.0.5.gem +0 -0
  93. data/dolores_rpm-3.3.4.fork.gem +0 -0
  94. data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +0 -115
  95. data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +0 -122
@@ -9,39 +9,37 @@ module NewRelic
9
9
 
10
10
  class TransactionSample
11
11
 
12
- attr_accessor :params, :root_segment
13
- attr_accessor :profile
14
- attr_reader :root_segment
15
- attr_reader :params
16
- attr_reader :sample_id
12
+ attr_accessor :params, :root_segment, :profile, :force_persist, :guid
13
+ attr_reader :root_segment, :params, :sample_id
17
14
 
18
15
  @@start_time = Time.now
19
16
 
20
17
  include TransactionAnalysis
21
-
18
+
22
19
  def initialize(time = Time.now.to_f, sample_id = nil)
23
20
  @sample_id = sample_id || object_id
24
21
  @start_time = time
22
+ @params = { :segment_count => -1, :request_params => {} }
23
+ @segment_count = -1
25
24
  @root_segment = create_segment 0.0, "ROOT"
26
- @params = {}
27
- @params[:request_params] = {}
25
+
26
+ @guid = generate_guid
27
+ NewRelic::Agent::TransactionInfo.get.guid = @guid
28
28
  end
29
29
 
30
30
  def count_segments
31
- @root_segment.count_segments - 1 # don't count the root segment
31
+ @segment_count
32
32
  end
33
-
33
+
34
34
  # Truncates the transaction sample to a maximum length determined
35
35
  # by the passed-in parameter. Operates recursively on the entire
36
36
  # tree of transaction segments in a depth-first manner
37
37
  def truncate(max)
38
- count = count_segments
39
- return if count < max
38
+ return if @segment_count < max
40
39
  @root_segment.truncate(max + 1)
41
-
42
- ensure_segment_count_set(count)
40
+ @segment_count = max
43
41
  end
44
-
42
+
45
43
  # makes sure that the parameter cache for segment count is set to
46
44
  # the correct value
47
45
  def ensure_segment_count_set(count)
@@ -74,13 +72,15 @@ module NewRelic
74
72
 
75
73
  def create_segment(relative_timestamp, metric_name, segment_id = nil)
76
74
  raise TypeError.new("Frozen Transaction Sample") if frozen?
75
+ @params[:segment_count] += 1
76
+ @segment_count += 1
77
77
  NewRelic::TransactionSample::Segment.new(relative_timestamp, metric_name, segment_id)
78
78
  end
79
79
 
80
80
  def duration
81
81
  root_segment.duration
82
82
  end
83
-
83
+
84
84
  # Iterates recursively over each segment in the entire transaction
85
85
  # sample tree
86
86
  def each_segment(&block)
@@ -96,7 +96,7 @@ module NewRelic
96
96
  def to_s_compact
97
97
  @root_segment.to_s_compact
98
98
  end
99
-
99
+
100
100
  # Searches the tree recursively for the segment with the given
101
101
  # id. note that this is an internal id, not an ActiveRecord id
102
102
  def find_segment(id)
@@ -115,6 +115,7 @@ module NewRelic
115
115
  when Enumerable then v.map(&:to_s).sort.join("; ")
116
116
  when String then v
117
117
  when Float then '%6.3s' % v
118
+ when Fixnum then v.to_s
118
119
  when nil then ''
119
120
  else
120
121
  raise "unexpected value type for #{k}: '#{v}' (#{v.class})"
@@ -133,9 +134,10 @@ module NewRelic
133
134
  regex = Regexp.new(regex)
134
135
 
135
136
  sample = TransactionSample.new(@start_time, sample_id)
136
-
137
- params.each {|k,v| sample.params[k] = v}
138
-
137
+
138
+ sample.params = params.dup
139
+ sample.params[:segment_count] = 0
140
+
139
141
  delta = build_segment_with_omissions(sample, 0.0, @root_segment, sample.root_segment, regex)
140
142
  sample.root_segment.end_trace(@root_segment.exit_timestamp - delta)
141
143
  sample.profile = self.profile
@@ -154,6 +156,8 @@ module NewRelic
154
156
  sample = TransactionSample.new(@start_time, sample_id)
155
157
 
156
158
  sample.params.merge! self.params
159
+ sample.guid = self.guid
160
+ sample.force_persist = self.force_persist if self.force_persist
157
161
 
158
162
  begin
159
163
  build_segment_for_transfer(sample, @root_segment, sample.root_segment, options)
@@ -170,7 +174,19 @@ module NewRelic
170
174
  end
171
175
 
172
176
  private
173
-
177
+
178
+
179
+
180
+ HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
181
+ # generate a random 64 bit uuid
182
+ def generate_guid
183
+ guid = ''
184
+ HEX_DIGITS.each do |a|
185
+ guid << HEX_DIGITS[rand(16)]
186
+ end
187
+ guid
188
+ end
189
+
174
190
  # This is badly in need of refactoring
175
191
  def build_segment_with_omissions(new_sample, time_delta, source_segment, target_segment, regex)
176
192
  source_segment.called_segments.each do |source_called_segment|
@@ -223,12 +239,12 @@ module NewRelic
223
239
  source_called_segment.duration > options[:explain_sql].to_f
224
240
  target_called_segment[:explain_plan] = source_called_segment.explain_sql
225
241
  end
226
-
242
+
227
243
  target_called_segment[:sql] = case options[:record_sql]
228
244
  when :raw then v
229
245
  when :obfuscated then NewRelic::Agent::Database.obfuscate_sql(v)
230
246
  else raise "Invalid value for record_sql: #{options[:record_sql]}"
231
- end if options[:record_sql]
247
+ end.to_s if options[:record_sql]
232
248
  when :connection_config
233
249
  # don't copy it
234
250
  else
@@ -2,9 +2,9 @@
2
2
  module NewRelic
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 3
5
- MINOR = 2
6
- TINY = 0
7
- BUILD = 6 #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
5
+ MINOR = 3
6
+ TINY = 4
7
+ BUILD = 'fork' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
10
10
 
@@ -12,7 +12,7 @@ module ActiveRecordFixtures
12
12
  ActiveRecordFixtures::Order.teardown
13
13
  begin
14
14
  super
15
- rescue Exception => e
15
+ rescue => e
16
16
  end
17
17
  end
18
18
  class Order < ActiveRecord::Base
@@ -30,7 +30,7 @@ module ActiveRecordFixtures
30
30
 
31
31
  def self.check_for_table
32
32
  connection.table_exists?(self.table_name)
33
- rescue Exception => e
33
+ rescue => e
34
34
  false
35
35
  end
36
36
 
@@ -66,7 +66,7 @@ module ActiveRecordFixtures
66
66
  end
67
67
  def self.check_for_table
68
68
  connection.table_exists?(self.table_name) && connection.table_exists?('orders_shipments')
69
- rescue Exception => e
69
+ rescue => e
70
70
  false
71
71
  end
72
72