appoptics_apm 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile_test +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +3 -2
  5. data/appoptics_apm.gemspec +2 -2
  6. data/docker-compose.yml +0 -22
  7. data/ext/oboe_metal/extconf.rb +4 -0
  8. data/lib/appoptics_apm/config.rb +11 -6
  9. data/lib/appoptics_apm/version.rb +1 -1
  10. metadata +3 -202
  11. data/gemfiles/delayed_job.gemfile +0 -36
  12. data/gemfiles/frameworks.gemfile +0 -44
  13. data/gemfiles/instrumentation_mocked.gemfile +0 -29
  14. data/gemfiles/libraries.gemfile +0 -85
  15. data/gemfiles/noop.gemfile +0 -17
  16. data/gemfiles/rails23.gemfile +0 -39
  17. data/gemfiles/rails30.gemfile +0 -42
  18. data/gemfiles/rails31.gemfile +0 -44
  19. data/gemfiles/rails32.gemfile +0 -54
  20. data/gemfiles/rails40.gemfile +0 -27
  21. data/gemfiles/rails41.gemfile +0 -27
  22. data/gemfiles/rails42.gemfile +0 -35
  23. data/gemfiles/rails50.gemfile +0 -44
  24. data/gemfiles/rails51.gemfile +0 -44
  25. data/test/benchmark/README.md +0 -65
  26. data/test/benchmark/logging_bench.rb +0 -54
  27. data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
  28. data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
  29. data/test/frameworks/apps/grape_nested.rb +0 -33
  30. data/test/frameworks/apps/grape_simple.rb +0 -80
  31. data/test/frameworks/apps/padrino_simple.rb +0 -80
  32. data/test/frameworks/apps/sinatra_simple.rb +0 -55
  33. data/test/frameworks/grape_test.rb +0 -286
  34. data/test/frameworks/padrino_test.rb +0 -222
  35. data/test/frameworks/rails3x_test.rb +0 -554
  36. data/test/frameworks/rails4x_test.rb +0 -570
  37. data/test/frameworks/rails5x_api_test.rb +0 -210
  38. data/test/frameworks/rails5x_test.rb +0 -376
  39. data/test/frameworks/rails_shared_tests.rb +0 -172
  40. data/test/frameworks/sinatra_test.rb +0 -140
  41. data/test/instrumentation/bunny_client_test.rb +0 -276
  42. data/test/instrumentation/bunny_consumer_test.rb +0 -204
  43. data/test/instrumentation/curb_test.rb +0 -398
  44. data/test/instrumentation/dalli_test.rb +0 -177
  45. data/test/instrumentation/em_http_request_test.rb +0 -89
  46. data/test/instrumentation/excon_test.rb +0 -231
  47. data/test/instrumentation/faraday_test.rb +0 -228
  48. data/test/instrumentation/http_test.rb +0 -143
  49. data/test/instrumentation/httpclient_test.rb +0 -304
  50. data/test/instrumentation/memcache_test.rb +0 -260
  51. data/test/instrumentation/memcached_test.rb +0 -229
  52. data/test/instrumentation/mongo_v1_test.rb +0 -479
  53. data/test/instrumentation/mongo_v2_index_test.rb +0 -124
  54. data/test/instrumentation/mongo_v2_test.rb +0 -584
  55. data/test/instrumentation/mongo_v2_view_test.rb +0 -435
  56. data/test/instrumentation/moped_test.rb +0 -517
  57. data/test/instrumentation/rack_test.rb +0 -165
  58. data/test/instrumentation/redis_hashes_test.rb +0 -268
  59. data/test/instrumentation/redis_keys_test.rb +0 -321
  60. data/test/instrumentation/redis_lists_test.rb +0 -310
  61. data/test/instrumentation/redis_misc_test.rb +0 -163
  62. data/test/instrumentation/redis_sets_test.rb +0 -296
  63. data/test/instrumentation/redis_sortedsets_test.rb +0 -328
  64. data/test/instrumentation/redis_strings_test.rb +0 -349
  65. data/test/instrumentation/resque_test.rb +0 -185
  66. data/test/instrumentation/rest-client_test.rb +0 -288
  67. data/test/instrumentation/sequel_mysql2_test.rb +0 -353
  68. data/test/instrumentation/sequel_mysql_test.rb +0 -334
  69. data/test/instrumentation/sequel_pg_test.rb +0 -336
  70. data/test/instrumentation/sidekiq-client_test.rb +0 -159
  71. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  72. data/test/instrumentation/twitter-cassandra_test.rb +0 -424
  73. data/test/instrumentation/typhoeus_test.rb +0 -284
  74. data/test/jobs/delayed_job/db_worker_job.rb +0 -29
  75. data/test/jobs/delayed_job/error_worker_job.rb +0 -10
  76. data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
  77. data/test/jobs/resque/db_worker_job.rb +0 -29
  78. data/test/jobs/resque/error_worker_job.rb +0 -10
  79. data/test/jobs/resque/remote_call_worker_job.rb +0 -20
  80. data/test/jobs/sidekiq/db_worker_job.rb +0 -29
  81. data/test/jobs/sidekiq/error_worker_job.rb +0 -10
  82. data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
  83. data/test/minitest_helper.rb +0 -277
  84. data/test/mocked/curb_mocked_test.rb +0 -324
  85. data/test/mocked/excon_mocked_test.rb +0 -174
  86. data/test/mocked/faraday_mocked_test.rb +0 -97
  87. data/test/mocked/http_mocked_test.rb +0 -135
  88. data/test/mocked/httpclient_mocked_test.rb +0 -258
  89. data/test/mocked/rest_client_mocked_test.rb +0 -109
  90. data/test/mocked/typhoeus_mocked_test.rb +0 -207
  91. data/test/models/widget.rb +0 -36
  92. data/test/noop/noop_test.rb +0 -145
  93. data/test/profiling/legacy_method_profiling_test.rb +0 -201
  94. data/test/profiling/method_profiling_test.rb +0 -631
  95. data/test/queues/delayed_job-client_test.rb +0 -95
  96. data/test/queues/delayed_job-worker_test.rb +0 -91
  97. data/test/reporter/reporter_test.rb +0 -14
  98. data/test/servers/delayed_job.rb +0 -107
  99. data/test/servers/rackapp_8101.rb +0 -29
  100. data/test/servers/rails3x_8140.rb +0 -96
  101. data/test/servers/rails4x_8140.rb +0 -96
  102. data/test/servers/rails5x_8140.rb +0 -95
  103. data/test/servers/rails5x_api_8150.rb +0 -78
  104. data/test/servers/sidekiq.rb +0 -29
  105. data/test/servers/sidekiq.yml +0 -7
  106. data/test/servers/sidekiq_initializer.rb +0 -25
  107. data/test/settings +0 -0
  108. data/test/support/auto_tracing_test.rb +0 -50
  109. data/test/support/backcompat_test.rb +0 -276
  110. data/test/support/config_test.rb +0 -149
  111. data/test/support/dnt_test.rb +0 -98
  112. data/test/support/init_report_test.rb +0 -25
  113. data/test/support/liboboe_settings_test.rb +0 -110
  114. data/test/support/logging_test.rb +0 -130
  115. data/test/support/sql_sanitize_test.rb +0 -55
  116. data/test/support/tracing_mode_test.rb +0 -33
  117. data/test/support/tvalias_test.rb +0 -15
  118. data/test/support/xtrace_test.rb +0 -41
@@ -1,201 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require 'minitest_helper'
5
-
6
- describe "LegacyAppOpticsAPMMethodProfiling" do
7
- before do
8
- clear_all_traces
9
- # Conditionally Undefine TestWorker
10
- # http://stackoverflow.com/questions/11503558/how-to-undefine-class-in-ruby
11
- Object.send(:remove_const, :TestWorker) if defined?(TestWorker)
12
- end
13
-
14
- it 'should be loaded, defined and ready' do
15
- defined?(::AppOpticsAPMMethodProfiling).wont_match nil
16
- end
17
-
18
- it 'should trace Class methods' do
19
- class TestWorker
20
- def self.do_work
21
- sleep 1
22
- end
23
-
24
- class << self
25
- include AppOpticsAPMMethodProfiling
26
- profile_method :do_work, 'do_work'
27
- end
28
- end
29
-
30
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
31
- # Call the profiled class method
32
- TestWorker.do_work
33
- end
34
-
35
- traces = get_all_traces
36
- traces.count.must_equal 4
37
-
38
- validate_outer_layers(traces, 'method_profiling')
39
-
40
- kvs = {}
41
- kvs["Label"] = 'profile_entry'
42
- kvs["Language"] = "ruby"
43
- kvs["ProfileName"] = "do_work"
44
- kvs["FunctionName"] = "do_work"
45
- kvs["Class"] = "TestWorker"
46
-
47
- validate_event_keys(traces[1], kvs)
48
-
49
- traces[1].has_key?("Layer").must_equal false
50
- traces[1].has_key?("File").must_equal true
51
- traces[1].has_key?("LineNumber").must_equal true
52
-
53
- kvs.clear
54
- kvs["Label"] = "profile_exit"
55
- kvs["Language"] = "ruby"
56
- kvs["ProfileName"] = "do_work"
57
-
58
- validate_event_keys(traces[2], kvs)
59
- traces[2].has_key?("Layer").must_equal false
60
- end
61
-
62
- it 'should trace Instance methods' do
63
- class TestWorker
64
- def do_work
65
- sleep 1
66
- end
67
-
68
- include AppOpticsAPMMethodProfiling
69
- profile_method :do_work, 'do_work'
70
- end
71
-
72
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
73
- # Call the profiled class method
74
- tw = TestWorker.new
75
- tw.do_work
76
- end
77
-
78
- traces = get_all_traces
79
- traces.count.must_equal 4
80
-
81
- validate_outer_layers(traces, 'method_profiling')
82
-
83
- kvs = {}
84
- kvs["Label"] = 'profile_entry'
85
- kvs["Language"] = "ruby"
86
- kvs["ProfileName"] = "do_work"
87
- kvs["FunctionName"] = "do_work"
88
- kvs["Class"] = "TestWorker"
89
-
90
- validate_event_keys(traces[1], kvs)
91
-
92
- traces[1].has_key?("Layer").must_equal false
93
- traces[1].has_key?("File").must_equal true
94
- traces[1].has_key?("LineNumber").must_equal true
95
-
96
- kvs.clear
97
- kvs["Label"] = "profile_exit"
98
- kvs["Language"] = "ruby"
99
- kvs["ProfileName"] = "do_work"
100
-
101
- validate_event_keys(traces[2], kvs)
102
- traces[2].has_key?("Layer").must_equal false
103
- end
104
-
105
- it 'should trace Module class methods' do
106
- module TestWorker
107
- def self.do_work
108
- sleep 1
109
- end
110
-
111
- class << self
112
- include AppOpticsAPMMethodProfiling
113
- profile_method :do_work, 'do_work'
114
- end
115
- end
116
-
117
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
118
- # Call the profiled class method
119
- TestWorker.do_work
120
- end
121
-
122
- traces = get_all_traces
123
- traces.count.must_equal 4
124
- validate_outer_layers(traces, 'method_profiling')
125
-
126
- kvs = {}
127
- kvs["Label"] = 'profile_entry'
128
- kvs["Language"] = "ruby"
129
- kvs["ProfileName"] = "do_work"
130
- kvs["FunctionName"] = "do_work"
131
- kvs["Module"] = "TestWorker"
132
-
133
- validate_event_keys(traces[1], kvs)
134
-
135
- traces[1].has_key?("Layer").must_equal false
136
- traces[1].has_key?("File").must_equal true
137
- traces[1].has_key?("LineNumber").must_equal true
138
-
139
- kvs.clear
140
- kvs["Label"] = "profile_exit"
141
- kvs["Language"] = "ruby"
142
- kvs["ProfileName"] = "do_work"
143
-
144
- validate_event_keys(traces[2], kvs)
145
- traces[2].has_key?("Layer").must_equal false
146
- end
147
-
148
- it 'should not store arguments and return value by default' do
149
- class TestWorker
150
- def self.do_work(_s, _i, _a, _h)
151
- sleep 1
152
- return "the zebra is loose"
153
- end
154
-
155
- class << self
156
- include AppOpticsAPMMethodProfiling
157
- # Default call method
158
- profile_method :do_work, 'do_work'
159
- end
160
- end
161
-
162
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
163
- # Call the profiled class method
164
- TestWorker.do_work('String Argument', 203984, ["1", "2", 3], { :color => :black })
165
- end
166
-
167
- traces = get_all_traces
168
- traces.count.must_equal 4
169
-
170
- traces[1].has_key?("Args").must_equal false
171
- traces[2].has_key?("ReturnValue").must_equal false
172
- end
173
-
174
- it 'should store arguments and return value when asked' do
175
- class TestWorker
176
- def self.do_work(_s, _i, _a, _h)
177
- sleep 1
178
- return "the zebra is loose"
179
- end
180
-
181
- class << self
182
- include AppOpticsAPMMethodProfiling
183
- profile_method :do_work, 'do_work', true, true
184
- end
185
- end
186
-
187
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
188
- # Call the profiled class method
189
- TestWorker.do_work('String Argument', 203984, ["1", "2", 3], { :color => :black })
190
- end
191
-
192
- traces = get_all_traces
193
- traces.count.must_equal 4
194
-
195
- traces[1].has_key?("Args").must_equal true
196
- traces[1]["Args"].must_equal "\"String Argument\"\n203984\n[\"1\", \"2\", 3]\n{:color=>:black}\n"
197
-
198
- traces[2].has_key?("ReturnValue").must_equal true
199
- traces[2]["ReturnValue"].must_equal "\"the zebra is loose\"\n"
200
- end
201
- end
@@ -1,631 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
- require 'minitest_helper'
4
-
5
- # APPOPTICS Method profiling only supports Ruby 1.9.3 or greater. For earlier Ruby versions
6
- # see the legacy method profiling in lib/appoptics_apm/legacy_method_profiling.rb.
7
- if RUBY_VERSION >= '1.9.3'
8
- describe "AppOpticsAPMMethodProfiling" do
9
- before do
10
- clear_all_traces
11
- # Conditionally Undefine TestWorker
12
- # http://stackoverflow.com/questions/11503558/how-to-undefine-class-in-ruby
13
- Object.send(:remove_const, :TestKlass) if defined?(TestKlass)
14
- Object.send(:remove_const, :TestModule) if defined?(TestModule)
15
- end
16
-
17
- it 'should be loaded, defined and ready' do
18
- defined?(::AppOpticsAPM::MethodProfiling).wont_match nil
19
- assert_equal true, AppOpticsAPM::API.respond_to?(:profile_method), "has profile_method method"
20
- end
21
-
22
- it 'should return false for bad arguments' do
23
- class TestKlass
24
- def do_work
25
- return 687
26
- end
27
- end
28
-
29
- # Bad first param
30
- rv = AppOpticsAPM::API.profile_method('blah', :do_work)
31
- assert_equal false, rv, "Return value must be false for bad args"
32
-
33
- # Bad first param
34
- rv = AppOpticsAPM::API.profile_method(TestKlass, 52)
35
- assert_equal false, rv, "Return value must be false for bad args"
36
- end
37
-
38
- it 'should profile class instance methods' do
39
- class TestKlass
40
- def do_work
41
- return 687
42
- end
43
- end
44
-
45
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
46
- assert_equal true, result, "profile_method return value must be true"
47
-
48
- result = nil
49
-
50
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
51
- # Call the profiled class method
52
- result = TestKlass.new.do_work
53
- end
54
-
55
- traces = get_all_traces
56
- traces.count.must_equal 4
57
- assert valid_edges?(traces), "Trace edge validation"
58
-
59
- validate_outer_layers(traces, 'method_profiling')
60
-
61
- result.must_equal 687
62
-
63
- kvs = {}
64
- kvs["Label"] = 'profile_entry'
65
- kvs["Language"] = "ruby"
66
- kvs["ProfileName"] = "do_work"
67
- kvs["Class"] = "TestKlass"
68
- kvs["MethodName"] = "do_work"
69
-
70
- validate_event_keys(traces[1], kvs)
71
-
72
- traces[1].key?("Layer").must_equal false
73
- traces[1].key?("Module").must_equal false
74
- traces[1].key?("File").must_equal true
75
- traces[1].key?("LineNumber").must_equal true
76
-
77
- kvs.clear
78
- kvs["Label"] = "profile_exit"
79
- kvs["Language"] = "ruby"
80
- kvs["ProfileName"] = "do_work"
81
-
82
- validate_event_keys(traces[2], kvs)
83
- traces[2].key?("Layer").must_equal false
84
- end
85
-
86
- it 'should not double profile already profiled methods' do
87
- class TestKlass
88
- def do_work
89
- return 687
90
- end
91
- end
92
-
93
- # Attempt to double profile
94
- rv = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
95
- assert_equal true, rv, "Return value must be true"
96
-
97
- rv = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
98
- assert_equal false, rv, "Return value must be false"
99
-
100
- with_tv = TestKlass.instance_methods.select{ |m| m == :do_work_with_appoptics }
101
- assert_equal with_tv.count, 1, ":do_work_with_appoptics method count"
102
-
103
- without_tv = TestKlass.instance_methods.select{ |m| m == :do_work_without_appoptics }
104
- assert_equal without_tv.count, 1, ":do_work_without_appoptics method count"
105
- end
106
-
107
- it 'should error out for non-existent methods' do
108
- class TestKlass
109
- def do_work
110
- return 687
111
- end
112
- end
113
-
114
- rv = AppOpticsAPM::API.profile_method(TestKlass, :does_not_exist)
115
- assert_equal false, rv, "Return value must be false"
116
-
117
- with_tv = TestKlass.instance_methods.select{ |m| m == :does_not_exit_with_appoptics }
118
- assert_equal with_tv.count, 0, ":does_not_exit_with_appoptics method count"
119
-
120
- without_tv = TestKlass.instance_methods.select{ |m| m == :does_not_exit_without_appoptics }
121
- assert_equal without_tv.count, 0, ":does_not_exit_without_appoptics method count"
122
- end
123
-
124
- it 'should trace class singleton methods' do
125
- class TestKlass
126
- def self.do_work
127
- return 687
128
- end
129
- end
130
-
131
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
132
- assert_equal true, result, "profile_method return value must be true"
133
-
134
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
135
- result = TestKlass.do_work
136
- end
137
-
138
- traces = get_all_traces
139
- traces.count.must_equal 4
140
- assert valid_edges?(traces), "Trace edge validation"
141
-
142
- validate_outer_layers(traces, 'method_profiling')
143
-
144
- result.must_equal 687
145
-
146
- kvs = {}
147
- kvs["Label"] = 'profile_entry'
148
- kvs["Language"] = "ruby"
149
- kvs["ProfileName"] = "do_work"
150
- kvs["Class"] = "TestKlass"
151
- kvs["MethodName"] = "do_work"
152
-
153
- validate_event_keys(traces[1], kvs)
154
-
155
- traces[1].key?("Layer").must_equal false
156
- traces[1].key?("Module").must_equal false
157
- traces[1].key?("File").must_equal true
158
- traces[1].key?("LineNumber").must_equal true
159
-
160
- kvs.clear
161
- kvs["Label"] = "profile_exit"
162
- kvs["Language"] = "ruby"
163
- kvs["ProfileName"] = "do_work"
164
-
165
- validate_event_keys(traces[2], kvs)
166
- traces[2].key?("Layer").must_equal false
167
- end
168
-
169
- it 'should trace class private instance methods' do
170
- class TestKlass
171
- private
172
- def do_work_privately
173
- return 687
174
- end
175
- end
176
-
177
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work_privately)
178
- assert_equal true, result, "profile_method return value must be true"
179
-
180
- result = nil
181
-
182
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
183
- # Call the profiled class method
184
- result = TestKlass.new.do_work_privately
185
- end
186
-
187
- traces = get_all_traces
188
- traces.count.must_equal 4
189
- assert valid_edges?(traces), "Trace edge validation"
190
-
191
- validate_outer_layers(traces, 'method_profiling')
192
-
193
- result.must_equal 687
194
-
195
- kvs = {}
196
- kvs["Label"] = 'profile_entry'
197
- kvs["Language"] = "ruby"
198
- kvs["ProfileName"] = "do_work_privately"
199
- kvs["Class"] = "TestKlass"
200
- kvs["MethodName"] = "do_work_privately"
201
-
202
- validate_event_keys(traces[1], kvs)
203
-
204
- traces[1].key?("Layer").must_equal false
205
- traces[1].key?("Module").must_equal false
206
- traces[1].key?("File").must_equal true
207
- traces[1].key?("LineNumber").must_equal true
208
-
209
- kvs.clear
210
- kvs["Label"] = "profile_exit"
211
- kvs["Language"] = "ruby"
212
- kvs["ProfileName"] = "do_work_privately"
213
-
214
- validate_event_keys(traces[2], kvs)
215
- traces[2].key?("Layer").must_equal false
216
- end
217
-
218
- it 'should trace class private singleton methods' do
219
- class TestKlass
220
- private
221
- def self.do_work_privately
222
- return 687
223
- end
224
- end
225
-
226
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work_privately)
227
- assert_equal true, result, "profile_method return value must be true"
228
-
229
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
230
- result = TestKlass.do_work_privately
231
- end
232
-
233
- traces = get_all_traces
234
- traces.count.must_equal 4
235
- assert valid_edges?(traces), "Trace edge validation"
236
-
237
- validate_outer_layers(traces, 'method_profiling')
238
-
239
- result.must_equal 687
240
-
241
- kvs = {}
242
- kvs["Label"] = 'profile_entry'
243
- kvs["Language"] = "ruby"
244
- kvs["ProfileName"] = "do_work_privately"
245
- kvs["Class"] = "TestKlass"
246
- kvs["MethodName"] = "do_work_privately"
247
-
248
- validate_event_keys(traces[1], kvs)
249
-
250
- traces[1].key?("Layer").must_equal false
251
- traces[1].key?("Module").must_equal false
252
- traces[1].key?("File").must_equal true
253
- traces[1].key?("LineNumber").must_equal true
254
-
255
- kvs.clear
256
- kvs["Label"] = "profile_exit"
257
- kvs["Language"] = "ruby"
258
- kvs["ProfileName"] = "do_work_privately"
259
-
260
- validate_event_keys(traces[2], kvs)
261
- traces[2].key?("Layer").must_equal false
262
- end
263
-
264
- it 'should trace module singleton methods' do
265
- module TestModule
266
- def self.do_work
267
- return 687
268
- end
269
- end
270
-
271
- result = AppOpticsAPM::API.profile_method(TestModule, :do_work)
272
- assert_equal true, result, "profile_method return value must be true"
273
-
274
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
275
- result = TestModule.do_work
276
- end
277
-
278
- traces = get_all_traces
279
- traces.count.must_equal 4
280
- assert valid_edges?(traces), "Trace edge validation"
281
-
282
- validate_outer_layers(traces, 'method_profiling')
283
-
284
- result.must_equal 687
285
-
286
- kvs = {}
287
- kvs["Label"] = 'profile_entry'
288
- kvs["Language"] = "ruby"
289
- kvs["ProfileName"] = "do_work"
290
- kvs["Module"] = "TestModule"
291
- kvs["MethodName"] = "do_work"
292
-
293
- validate_event_keys(traces[1], kvs)
294
-
295
- traces[1].key?("Layer").must_equal false
296
- traces[1].key?("Class").must_equal false
297
- traces[1].key?("File").must_equal true
298
- traces[1].key?("LineNumber").must_equal true
299
-
300
- kvs.clear
301
- kvs["Label"] = "profile_exit"
302
- kvs["Language"] = "ruby"
303
- kvs["ProfileName"] = "do_work"
304
-
305
- validate_event_keys(traces[2], kvs)
306
- traces[2].key?("Layer").must_equal false
307
- end
308
-
309
- it 'should trace module instance methods' do
310
- module TestModule
311
- def do_work
312
- return 687
313
- end
314
- end
315
-
316
- # Profile the module before including in a class
317
- result = AppOpticsAPM::API.profile_method(TestModule, :do_work)
318
- assert_equal true, result, "profile_method return value must be true"
319
-
320
- class TestKlass
321
- include TestModule
322
- end
323
-
324
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
325
- result = TestKlass.new.do_work
326
- end
327
-
328
- traces = get_all_traces
329
- traces.count.must_equal 4
330
- assert valid_edges?(traces), "Trace edge validation"
331
-
332
- validate_outer_layers(traces, 'method_profiling')
333
-
334
- result.must_equal 687
335
-
336
- kvs = {}
337
- kvs["Label"] = 'profile_entry'
338
- kvs["Language"] = "ruby"
339
- kvs["ProfileName"] = "do_work"
340
- kvs["Module"] = "TestModule"
341
- kvs["MethodName"] = "do_work"
342
-
343
- validate_event_keys(traces[1], kvs)
344
-
345
- traces[1].key?("Layer").must_equal false
346
- traces[1].key?("Class").must_equal false
347
- traces[1].key?("File").must_equal true
348
- traces[1].key?("LineNumber").must_equal true
349
-
350
- kvs.clear
351
- kvs["Label"] = "profile_exit"
352
- kvs["Language"] = "ruby"
353
- kvs["ProfileName"] = "do_work"
354
-
355
- validate_event_keys(traces[2], kvs)
356
- traces[2].key?("Layer").must_equal false
357
- end
358
-
359
- it 'should profile methods that use blocks' do
360
- class TestKlass
361
- def self.do_work(*)
362
- yield
363
- end
364
- end
365
-
366
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
367
- assert_equal true, result, "profile_method return value must be true"
368
-
369
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
370
- result = TestKlass.do_work do
371
- 787
372
- end
373
- end
374
-
375
- traces = get_all_traces
376
- traces.count.must_equal 4
377
- assert valid_edges?(traces), "Trace edge validation"
378
-
379
- validate_outer_layers(traces, 'method_profiling')
380
-
381
- result.must_equal 787
382
-
383
- kvs = {}
384
- kvs["Label"] = 'profile_entry'
385
- kvs["Language"] = "ruby"
386
- kvs["ProfileName"] = "do_work"
387
- kvs["Class"] = "TestKlass"
388
- kvs["MethodName"] = "do_work"
389
-
390
- validate_event_keys(traces[1], kvs)
391
-
392
- traces[1].key?("Layer").must_equal false
393
- traces[1].key?("Module").must_equal false
394
- traces[1].key?("File").must_equal true
395
- traces[1].key?("LineNumber").must_equal true
396
-
397
- kvs.clear
398
- kvs["Label"] = "profile_exit"
399
- kvs["Language"] = "ruby"
400
- kvs["ProfileName"] = "do_work"
401
-
402
- validate_event_keys(traces[2], kvs)
403
- traces[2].key?("Layer").must_equal false
404
- end
405
-
406
- it 'should not store arguments and return value by default' do
407
- class TestKlass
408
- def do_work(*)
409
- return 687
410
- end
411
- end
412
-
413
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
414
- assert_equal true, result, "profile_method return value must be true"
415
-
416
- result = nil
417
-
418
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
419
- # Call the profiled class method
420
- result = TestKlass.new.do_work(:ok => :blue)
421
- end
422
-
423
- traces = get_all_traces
424
- traces.count.must_equal 4
425
- assert valid_edges?(traces), "Trace edge validation"
426
-
427
- validate_outer_layers(traces, 'method_profiling')
428
-
429
- result.must_equal 687
430
-
431
- kvs = {}
432
- kvs["Label"] = 'profile_entry'
433
- kvs["Language"] = "ruby"
434
- kvs["ProfileName"] = "do_work"
435
- kvs["Class"] = "TestKlass"
436
- kvs["MethodName"] = "do_work"
437
-
438
- validate_event_keys(traces[1], kvs)
439
-
440
- traces[1].key?("Layer").must_equal false
441
- traces[1].key?("Module").must_equal false
442
- traces[1].key?("File").must_equal true
443
- traces[1].key?("LineNumber").must_equal true
444
-
445
- kvs.clear
446
- kvs["Label"] = "profile_exit"
447
- kvs["Language"] = "ruby"
448
- kvs["ProfileName"] = "do_work"
449
-
450
- validate_event_keys(traces[2], kvs)
451
- traces[2].key?("Layer").must_equal false
452
-
453
- traces[2].key?("Arguments").must_equal false
454
- traces[2].key?("ReturnValue").must_equal false
455
- end
456
-
457
- it 'should store arguments and return value when asked' do
458
- class TestKlass
459
- def do_work(*)
460
- return 687
461
- end
462
- end
463
-
464
- opts = {}
465
- opts[:arguments] = true
466
- opts[:result] = true
467
-
468
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work, opts)
469
- assert_equal true, result, "profile_method return value must be true"
470
-
471
- result = nil
472
-
473
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
474
- # Call the profiled class method
475
- result = TestKlass.new.do_work(:ok => :blue)
476
- end
477
-
478
- traces = get_all_traces
479
- traces.count.must_equal 4
480
- assert valid_edges?(traces), "Trace edge validation"
481
-
482
- validate_outer_layers(traces, 'method_profiling')
483
-
484
- result.must_equal 687
485
-
486
- kvs = {}
487
- kvs["Label"] = 'profile_entry'
488
- kvs["Language"] = "ruby"
489
- kvs["ProfileName"] = "do_work"
490
- kvs["Class"] = "TestKlass"
491
- kvs["MethodName"] = "do_work"
492
-
493
- validate_event_keys(traces[1], kvs)
494
-
495
- traces[1].key?("Layer").must_equal false
496
- traces[1].key?("Module").must_equal false
497
- traces[1].key?("File").must_equal true
498
- traces[1].key?("LineNumber").must_equal true
499
-
500
- kvs.clear
501
- kvs["Label"] = "profile_exit"
502
- kvs["Language"] = "ruby"
503
- kvs["ProfileName"] = "do_work"
504
-
505
- validate_event_keys(traces[2], kvs)
506
- traces[2].key?("Layer").must_equal false
507
-
508
- traces[2].key?("Arguments").must_equal true
509
- traces[2]["Arguments"].must_equal "[{:ok=>:blue}]"
510
-
511
- traces[2].key?("ReturnValue").must_equal true
512
- traces[2]["ReturnValue"].must_equal 687
513
- end
514
-
515
- it 'should not report backtraces by default' do
516
- class TestKlass
517
- def do_work(*)
518
- return 687
519
- end
520
- end
521
-
522
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work)
523
- assert_equal true, result, "profile_method return value must be true"
524
-
525
- result = nil
526
-
527
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
528
- # Call the profiled class method
529
- result = TestKlass.new.do_work(:ok => :blue)
530
- end
531
-
532
- traces = get_all_traces
533
- traces.count.must_equal 4
534
- assert valid_edges?(traces), "Trace edge validation"
535
-
536
- validate_outer_layers(traces, 'method_profiling')
537
-
538
- result.must_equal 687
539
-
540
- kvs = {}
541
- kvs["Label"] = 'profile_entry'
542
- kvs["Language"] = "ruby"
543
- kvs["ProfileName"] = "do_work"
544
- kvs["Class"] = "TestKlass"
545
- kvs["MethodName"] = "do_work"
546
-
547
- validate_event_keys(traces[1], kvs)
548
-
549
- traces.each { |t|
550
- t.key?("Backtrace").must_equal false, "shoudn't have backtrace"
551
- }
552
- end
553
-
554
- it 'should report backtraces when requested' do
555
- class TestKlass
556
- def do_work(*)
557
- return 687
558
- end
559
- end
560
-
561
- opts = { :backtrace => true }
562
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work, opts)
563
- assert_equal true, result, "profile_method return value must be true"
564
-
565
- result = nil
566
-
567
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
568
- # Call the profiled class method
569
- result = TestKlass.new.do_work(:ok => :blue)
570
- end
571
-
572
- traces = get_all_traces
573
- traces.count.must_equal 4
574
- assert valid_edges?(traces), "Trace edge validation"
575
-
576
- validate_outer_layers(traces, 'method_profiling')
577
-
578
- result.must_equal 687
579
-
580
- kvs = {}
581
- kvs["Label"] = 'profile_entry'
582
- kvs["Language"] = "ruby"
583
- kvs["ProfileName"] = "do_work"
584
- kvs["Class"] = "TestKlass"
585
- kvs["MethodName"] = "do_work"
586
-
587
- validate_event_keys(traces[1], kvs)
588
-
589
- traces[1].key?("Backtrace").must_equal true, "should report a backtrace"
590
- end
591
-
592
- it 'should report extra KVs when requested' do
593
- class TestKlass
594
- def do_work(*)
595
- return 687
596
- end
597
- end
598
-
599
- opts = { :backtrace => true }
600
- result = AppOpticsAPM::API.profile_method(TestKlass, :do_work, opts, :another => "value")
601
- assert_equal true, result, "profile_method return value must be true"
602
-
603
- result = nil
604
-
605
- ::AppOpticsAPM::API.start_trace('method_profiling', '', {}) do
606
- # Call the profiled class method
607
- result = TestKlass.new.do_work(:ok => :blue)
608
- end
609
-
610
- traces = get_all_traces
611
- traces.count.must_equal 4
612
- assert valid_edges?(traces), "Trace edge validation"
613
-
614
- validate_outer_layers(traces, 'method_profiling')
615
-
616
- result.must_equal 687
617
-
618
- kvs = {}
619
- kvs["Label"] = 'profile_entry'
620
- kvs["Language"] = "ruby"
621
- kvs["ProfileName"] = "do_work"
622
- kvs["Class"] = "TestKlass"
623
- kvs["MethodName"] = "do_work"
624
- kvs["another"] = "value"
625
-
626
- validate_event_keys(traces[1], kvs)
627
-
628
- traces[1].key?("Backtrace").must_equal true, "should report a backtrace"
629
- end
630
- end
631
- end