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,95 +0,0 @@
1
- ##
2
- # Copyright (c) 2016 SolarWinds, LLC.
3
- # All rights reserved.
4
-
5
- # This is a Rails stack that launches on a background
6
- # thread and listens on port 8140.
7
- #
8
- if ENV['DBTYPE'] == 'mysql2'
9
- AppOpticsAPM::Test.set_mysql2_env
10
- elsif ENV['DBTYPE'] == 'postgresql'
11
- AppOpticsAPM::Test.set_postgresql_env
12
- else
13
- AppOpticsAPM.logger.warn "Unidentified DBTYPE: #{ENV['DBTYPE']}" unless ENV['DBTYPE'] == "postgresql"
14
- AppOpticsAPM.logger.debug "Defaulting to postgres DB for background Rails server."
15
- AppOpticsAPM::Test.set_postgresql_env
16
- end
17
-
18
- require "rails/all"
19
- require "action_controller/railtie" # require more if needed
20
- require 'rack/handler/puma'
21
- require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
22
-
23
- AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rails app on localhost:8140."
24
-
25
- ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
26
-
27
- unless ActiveRecord::Base.connection.table_exists? 'widgets'
28
- ActiveRecord::Migration.run(CreateWidgets)
29
- end
30
-
31
- class Rails50MetalStack < Rails::Application
32
- routes.append do
33
- get "/hello/world" => "hello#world"
34
- get "/hello/:id/show" => "hello#show"
35
- get "/hello/metal" => "ferro#world"
36
- get "/hello/db" => "hello#db"
37
- get "/hello/servererror" => "hello#servererror"
38
- end
39
-
40
- config.cache_classes = true
41
- config.eager_load = false
42
- config.active_support.deprecation = :stderr
43
- config.middleware.delete Rack::Lock
44
- config.middleware.delete ActionDispatch::Flash
45
- config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
46
- config.secret_key_base = "2048671-96803948"
47
- end
48
-
49
- #################################################
50
- # Controllers
51
- #################################################
52
-
53
- class HelloController < ActionController::Base
54
- def world
55
- render :plain => "Hello world!"
56
- end
57
-
58
- def show
59
- render :plain => "Hello Number #{params[:id]}"
60
- end
61
-
62
- def db
63
- # Create a widget
64
- w1 = Widget.new(:name => 'blah', :description => 'This is an amazing widget.')
65
- w1.save
66
-
67
- # query for that widget
68
- w2 = Widget.where(:name => 'blah').first
69
- w2.delete
70
-
71
- render :plain => "Hello database!"
72
- end
73
-
74
- def servererror
75
- render :plain => "broken", :status => 500
76
- end
77
- end
78
-
79
- class FerroController < ActionController::Metal
80
- include AbstractController::Rendering
81
-
82
- def world
83
- render :plain => "Hello world!"
84
- end
85
- end
86
-
87
- AppOpticsAPM::API.profile_method(FerroController, :world)
88
-
89
- Rails50MetalStack.initialize!
90
-
91
- Thread.new do
92
- Rack::Handler::Puma.run(Rails50MetalStack.to_app, {:Host => '127.0.0.1', :Port => 8140})
93
- end
94
-
95
- sleep(2)
@@ -1,78 +0,0 @@
1
- ##
2
- # Copyright (c) 2016 SolarWinds, LLC.
3
- # All rights reserved.
4
-
5
- # This is a Rails API stack that launches on a background
6
- # thread and listens on port 8150.
7
- #
8
- if ENV['DBTYPE'] == 'mysql2'
9
- AppOpticsAPM::Test.set_mysql2_env
10
- elsif ENV['DBTYPE'] == 'postgresql'
11
- AppOpticsAPM::Test.set_postgresql_env
12
- else
13
- AppOpticsAPM.logger.warn "Unidentified DBTYPE: #{ENV['DBTYPE']}" unless ENV['DBTYPE'] == "postgresql"
14
- AppOpticsAPM.logger.debug "Defaulting to postgres DB for background Rails server."
15
- AppOpticsAPM::Test.set_postgresql_env
16
- end
17
-
18
- require "rails"
19
- require "active_model/railtie"
20
- require "active_job/railtie"
21
- require "active_record/railtie"
22
- require "action_controller/railtie"
23
- require "action_mailer/railtie"
24
- require "action_view/railtie"
25
- require "action_cable/engine"
26
- require "rails/test_unit/railtie"
27
-
28
- require 'rack/handler/puma'
29
- require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
30
-
31
- AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rails app on localhost:8150."
32
-
33
- ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
34
-
35
- unless ActiveRecord::Base.connection.table_exists? 'widgets'
36
- ActiveRecord::Migration.run(CreateWidgets)
37
- end
38
-
39
- module Rails50APIStack
40
- class Application < Rails::Application
41
- config.api_only = true
42
-
43
- routes.append do
44
- get "/monkey/hello" => "monkey#hello"
45
- get "/monkey/error" => "monkey#error"
46
- end
47
-
48
- config.cache_classes = true
49
- config.eager_load = false
50
- config.active_support.deprecation = :stderr
51
- config.middleware.delete Rack::Lock
52
- config.middleware.delete ActionDispatch::Flash
53
- config.secret_token = "48837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
54
- config.secret_key_base = "2049671-96803948"
55
- end
56
- end
57
-
58
- #################################################
59
- # Controllers
60
- #################################################
61
-
62
- class MonkeyController < ActionController::API
63
- def hello
64
- render :plain => {:Response => "Hello API!"}.to_json, content_type: 'application/json'
65
- end
66
-
67
- def error
68
- raise "Rails API fake error from controller"
69
- end
70
- end
71
-
72
- Rails50APIStack::Application.initialize!
73
-
74
- Thread.new do
75
- Rack::Handler::Puma.run(Rails50APIStack::Application.to_app, {:Host => '127.0.0.1', :Port => 8150})
76
- end
77
-
78
- sleep(2)
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- # We configure and launch Sidekiq in a background
5
- # thread here.
6
- #
7
- require 'sidekiq/cli'
8
-
9
- AppOpticsAPM.logger.info "[appoptics_apm/servers] Starting up background Sidekiq."
10
-
11
- options = []
12
- arguments = ""
13
- options << ["-r", Dir.pwd + "/test/servers/sidekiq_initializer.rb"]
14
- options << ["-q", "critical,20", "-q", "default"]
15
- options << ["-c", "10"]
16
- options << ["-P", "/tmp/sidekiq_#{Process.pid}.pid"]
17
-
18
- options.flatten.each do |x|
19
- arguments += " #{x}"
20
- end
21
-
22
- AppOpticsAPM.logger.debug "[appoptics_apm/servers] sidekiq #{arguments}"
23
-
24
- Thread.new do
25
- system("OBOE_GEM_TEST=true sidekiq #{arguments}")
26
- end
27
-
28
- # Allow Sidekiq to boot up
29
- sleep 10
@@ -1,7 +0,0 @@
1
- ---
2
- :concurrency: 2
3
- :pidfile: tmp/pids/sidekiq.pid
4
- :queues:
5
- - default
6
- - [critical, 2]
7
- - [low, 1]
@@ -1,25 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- # This file is used to initialize the background Sidekiq
5
- # process launched in our test suite.
6
- #
7
- ENV['BUNDLE_GEMFILE'] = Dir.pwd + "/gemfiles/libraries.gemfile"
8
-
9
- require 'rubygems'
10
- require 'bundler/setup'
11
- require_relative '../jobs/sidekiq/db_worker_job'
12
- require_relative '../jobs/sidekiq/remote_call_worker_job'
13
- require_relative '../jobs/sidekiq/error_worker_job'
14
-
15
- ENV["RACK_ENV"] = "test"
16
- ENV["APPOPTICS_GEM_TEST"] = "true"
17
- ENV["APPOPTICS_GEM_VERBOSE"] = "true"
18
-
19
- Bundler.require(:default, :test)
20
-
21
- # Configure AppOpticsAPM
22
- AppOpticsAPM::Config[:tracing_mode] = "always"
23
- AppOpticsAPM::Config[:sample_rate] = 1000000
24
- AppOpticsAPM.logger.level = Logger::DEBUG
25
-
data/test/settings DELETED
Binary file
@@ -1,50 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require 'minitest_helper'
5
-
6
- class AutoTraceTest < Minitest::Test
7
- def setup
8
- @tm = AppOpticsAPM::Config[:tracing_mode]
9
- end
10
-
11
- def teardown
12
- AppOpticsAPM::Config[:tracing_mode] = @tm
13
- end
14
-
15
- def test_trace_when_default_tm_dj
16
- AppOpticsAPM::API.start_trace('delayed_job-worker') do
17
- AppOpticsAPM.tracing?.must_equal true
18
- end
19
- end
20
-
21
- def test_trace_when_default_tm_sidekiq
22
- AppOpticsAPM::API.start_trace('sidekiq-worker') do
23
- AppOpticsAPM.tracing?.must_equal true
24
- end
25
- end
26
-
27
- def test_trace_when_default_tm_resque
28
- AppOpticsAPM::API.start_trace('resque-worker') do
29
- AppOpticsAPM.tracing?.must_equal true
30
- end
31
- end
32
-
33
- def test_trace_when_default_tm_rabbitmq
34
- AppOpticsAPM::API.start_trace('rabbitmq-consumer') do
35
- AppOpticsAPM.tracing?.must_equal true
36
- end
37
- end
38
-
39
- def test_dont_trace_when_never
40
- AppOpticsAPM::Config[:tracing_mode] = :never
41
-
42
- AppOpticsAPM::API.start_trace('delayed_job-worker') do
43
- AppOpticsAPM.tracing?.must_equal false
44
- end
45
-
46
- AppOpticsAPM::API.start_trace('asdf') do
47
- AppOpticsAPM.tracing?.must_equal false
48
- end
49
- end
50
- end
@@ -1,276 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require 'minitest_helper'
5
-
6
- describe "BackwardCompatibility" do
7
-
8
- it 'should still export to Oboe::Ruby' do
9
- defined?(::Oboe::Ruby).must_equal "constant"
10
- end
11
-
12
- it 'should still respond to Oboe::Config' do
13
- @verbose = Oboe::Config[:verbose]
14
- @dalli_enabled = Oboe::Config[:dalli][:enabled]
15
- @tm = Oboe::Config[:tracing_mode]
16
- @sr = Oboe::Config[:sample_rate]
17
-
18
- Oboe::Config[:verbose] = true
19
- Oboe::Config[:verbose].must_equal true
20
- Oboe::Config.verbose.must_equal true
21
- AppOpticsAPM::Config[:verbose].must_equal true
22
- AppOpticsAPM::Config.verbose.must_equal true
23
-
24
- Oboe::Config[:dalli][:enabled] = false
25
- Oboe::Config[:dalli][:enabled].must_equal false
26
- AppOpticsAPM::Config[:dalli][:enabled].must_equal false
27
-
28
- Oboe::Config[:sample_rate] = 8e5
29
- Oboe::Config.sample_rate.must_equal 8e5
30
- AppOpticsAPM::Config.sample_rate.must_equal 8e5
31
-
32
- Oboe::Config[:tracing_mode] = 'always'
33
- Oboe::Config.tracing_mode.must_equal :always
34
- AppOpticsAPM::Config.tracing_mode.must_equal :always
35
-
36
- Oboe::Config[:sample_rate] = @sr
37
- Oboe::Config[:tracing_mode] = @tm
38
- Oboe::Config[:dalli][:enabled] = @dalli_enabled
39
- Oboe::Config[:verbose] = @verbose
40
- end
41
-
42
- it 'should still support Oboe::API.log calls' do
43
- clear_all_traces
44
-
45
- Oboe::API.log_start('rack', nil, {})
46
- Oboe::API.log_end('rack')
47
-
48
- traces = get_all_traces
49
- traces.count.must_equal 2
50
- end
51
-
52
- it 'should still support Oboe::API.trace calls' do
53
- clear_all_traces
54
-
55
- Oboe::API.start_trace('api_test', '', {}) do
56
- sleep 1
57
- end
58
-
59
- traces = get_all_traces
60
- traces.count.must_equal 2
61
-
62
- validate_outer_layers(traces, 'api_test')
63
- end
64
-
65
- it 'should still support Oboe::API.profile'do
66
- clear_all_traces
67
-
68
- Oboe::API.start_trace('outer_profile_test') do
69
- Oboe::API.profile('profile_test', {}, false) do
70
- sleep 1
71
- end
72
- end
73
-
74
- traces = get_all_traces
75
- traces.count.must_equal 4
76
- end
77
-
78
- # Pasted in from test/profiling/method_test.rb
79
- # Modified to use OboeMethodProfiling
80
- describe "OboeMethodProfiling" do
81
- before do
82
- clear_all_traces
83
- # Conditionally Undefine TestWorker
84
- # http://stackoverflow.com/questions/11503558/how-to-undefine-class-in-ruby
85
- Object.send(:remove_const, :TestWorker) if defined?(TestWorker)
86
- end
87
-
88
- it 'should be loaded, defined and ready' do
89
- defined?(::OboeMethodProfiling).wont_match nil
90
- end
91
-
92
- it 'should trace Class methods' do
93
- class TestWorker
94
- def self.do_work
95
- sleep 1
96
- end
97
-
98
- class << self
99
- include OboeMethodProfiling
100
- profile_method :do_work, 'do_work'
101
- end
102
- end
103
-
104
- ::Oboe::API.start_trace('method_profiling', '', {}) do
105
- # Call the profiled class method
106
- TestWorker.do_work
107
- end
108
-
109
- traces = get_all_traces
110
- traces.count.must_equal 4
111
-
112
- validate_outer_layers(traces, 'method_profiling')
113
-
114
- kvs = {}
115
- kvs["Label"] = 'profile_entry'
116
- kvs["Language"] = "ruby"
117
- kvs["ProfileName"] = "do_work"
118
- kvs["FunctionName"] = "do_work"
119
- kvs["Class"] = "TestWorker"
120
-
121
- validate_event_keys(traces[1], kvs)
122
-
123
- traces[1].has_key?("Layer").must_equal false
124
- traces[1].has_key?("File").must_equal true
125
- traces[1].has_key?("LineNumber").must_equal true
126
-
127
- kvs.clear
128
- kvs["Label"] = "profile_exit"
129
- kvs["Language"] = "ruby"
130
- kvs["ProfileName"] = "do_work"
131
-
132
- validate_event_keys(traces[2], kvs)
133
- traces[2].has_key?("Layer").must_equal false
134
- end
135
-
136
- it 'should trace Instance methods' do
137
- class TestWorker
138
- def do_work
139
- sleep 1
140
- end
141
-
142
- include OboeMethodProfiling
143
- profile_method :do_work, 'do_work'
144
- end
145
-
146
- ::Oboe::API.start_trace('method_profiling', '', {}) do
147
- # Call the profiled class method
148
- tw = TestWorker.new
149
- tw.do_work
150
- end
151
-
152
- traces = get_all_traces
153
- traces.count.must_equal 4
154
-
155
- validate_outer_layers(traces, 'method_profiling')
156
-
157
- kvs = {}
158
- kvs["Label"] = 'profile_entry'
159
- kvs["Language"] = "ruby"
160
- kvs["ProfileName"] = "do_work"
161
- kvs["FunctionName"] = "do_work"
162
- kvs["Class"] = "TestWorker"
163
-
164
- validate_event_keys(traces[1], kvs)
165
-
166
- traces[1].has_key?("Layer").must_equal false
167
- traces[1].has_key?("File").must_equal true
168
- traces[1].has_key?("LineNumber").must_equal true
169
-
170
- kvs.clear
171
- kvs["Label"] = "profile_exit"
172
- kvs["Language"] = "ruby"
173
- kvs["ProfileName"] = "do_work"
174
-
175
- validate_event_keys(traces[2], kvs)
176
- traces[2].has_key?("Layer").must_equal false
177
- end
178
-
179
- it 'should trace Module class methods' do
180
- module TestWorker
181
- def self.do_work
182
- sleep 1
183
- end
184
-
185
- class << self
186
- include OboeMethodProfiling
187
- profile_method :do_work, 'do_work'
188
- end
189
- end
190
-
191
- ::Oboe::API.start_trace('method_profiling', '', {}) do
192
- # Call the profiled class method
193
- TestWorker.do_work
194
- end
195
-
196
- traces = get_all_traces
197
- traces.count.must_equal 4
198
- validate_outer_layers(traces, 'method_profiling')
199
-
200
- kvs = {}
201
- kvs["Label"] = 'profile_entry'
202
- kvs["Language"] = "ruby"
203
- kvs["ProfileName"] = "do_work"
204
- kvs["FunctionName"] = "do_work"
205
- kvs["Module"] = "TestWorker"
206
-
207
- validate_event_keys(traces[1], kvs)
208
-
209
- traces[1].has_key?("Layer").must_equal false
210
- traces[1].has_key?("File").must_equal true
211
- traces[1].has_key?("LineNumber").must_equal true
212
-
213
- kvs.clear
214
- kvs["Label"] = "profile_exit"
215
- kvs["Language"] = "ruby"
216
- kvs["ProfileName"] = "do_work"
217
-
218
- validate_event_keys(traces[2], kvs)
219
- traces[2].has_key?("Layer").must_equal false
220
- end
221
-
222
- it 'should not store arguments and return value by default' do
223
- class TestWorker
224
- def self.do_work(_s, _i, _a, _h)
225
- sleep 1
226
- return "the zebra is loose"
227
- end
228
-
229
- class << self
230
- include OboeMethodProfiling
231
- # Default call method
232
- profile_method :do_work, 'do_work'
233
- end
234
- end
235
-
236
- ::Oboe::API.start_trace('method_profiling', '', {}) do
237
- # Call the profiled class method
238
- TestWorker.do_work('String Argument', 203984, ["1", "2", 3], { :color => :black })
239
- end
240
-
241
- traces = get_all_traces
242
- traces.count.must_equal 4
243
-
244
- traces[1].has_key?("Args").must_equal false
245
- traces[2].has_key?("ReturnValue").must_equal false
246
- end
247
-
248
- it 'should store arguments and return value when asked' do
249
- class TestWorker
250
- def self.do_work(_s, _i, _a, _h)
251
- sleep 1
252
- return "the zebra is loose"
253
- end
254
-
255
- class << self
256
- include OboeMethodProfiling
257
- profile_method :do_work, 'do_work', true, true
258
- end
259
- end
260
-
261
- ::Oboe::API.start_trace('method_profiling', '', {}) do
262
- # Call the profiled class method
263
- TestWorker.do_work('String Argument', 203984, ["1", "2", 3], { :color => :black })
264
- end
265
-
266
- traces = get_all_traces
267
- traces.count.must_equal 4
268
-
269
- traces[1].has_key?("Args").must_equal true
270
- traces[1]["Args"].must_equal "\"String Argument\"\n203984\n[\"1\", \"2\", 3]\n{:color=>:black}\n"
271
-
272
- traces[2].has_key?("ReturnValue").must_equal true
273
- traces[2]["ReturnValue"].must_equal "\"the zebra is loose\"\n"
274
- end
275
- end
276
- end