oboe 1.3.8 → 1.3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,78 +2,76 @@
2
2
  # All rights reserved.
3
3
 
4
4
  module OboeMethodProfiling
5
- def self.included klass
6
- klass.extend ClassMethods
7
- end
5
+ def self.included klass
6
+ klass.extend ClassMethods
7
+ end
8
8
 
9
- module ClassMethods
10
- def profile_method(method_name, profile_name, store_args=false, store_return=false, profile=false)
11
- #this only gets file and line where profiling is turned on, presumably
12
- #right after the function definition. ruby 1.9 has nice introspection (Method.source_location)
13
- #but its appears no such luck for ruby 1.8
14
- version = RbConfig::CONFIG['ruby_version']
15
- file = nil
16
- line = nil
17
- if version and version.match(/^1.9/)
18
- info = self.method(method_name).source_location
19
- if !info.nil?
20
- file = info[0]
21
- line = info[1]
22
- end
23
- else
24
- info = Kernel.caller[0].split(':')
25
- file = info.first
26
- line = info.last
27
- end
9
+ module ClassMethods
10
+ def profile_method(method_name, profile_name, store_args=false, store_return=false, profile=false)
11
+ #this only gets file and line where profiling is turned on, presumably
12
+ #right after the function definition. ruby 1.9 has nice introspection (Method.source_location)
13
+ #but its appears no such luck for ruby 1.8
14
+ version = RbConfig::CONFIG['ruby_version']
15
+ file = nil
16
+ line = nil
17
+ if version and version.match(/^1.9/)
18
+ info = self.instance_method(method_name).source_location
19
+ if !info.nil?
20
+ file = info[0]
21
+ line = info[1]
22
+ end
23
+ else
24
+ info = Kernel.caller[0].split(':')
25
+ file = info.first
26
+ line = info.last
27
+ end
28
28
 
29
- #profiling via ruby-prof, is it possible to get return value of profiled code?
30
- code = "def _oboe_profiled_#{method_name}(*args, &block)
31
- def pps(*args)
32
- old_out = $stdout
33
- begin
34
- s = StringIO.new
35
- $stdout = s
36
- pp(*args)
37
- ensure
38
- $stdout = old_out
39
- end
40
- s.string
41
- end
29
+ #profiling via ruby-prof, is it possible to get return value of profiled code?
30
+ code = "def _oboe_profiled_#{method_name}(*args, &block)
31
+ def pps(*args)
32
+ old_out = $stdout
33
+ begin
34
+ s = StringIO.new
35
+ $stdout = s
36
+ pp(*args)
37
+ ensure
38
+ $stdout = old_out
39
+ end
40
+ s.string
41
+ end
42
42
 
43
- # file and line number are fetched in Context.log
44
- # because we have access to the correct backtrace there
45
- entry_kvs = {'Language' => 'ruby',
46
- 'ProfileName' => '#{profile_name}',
47
- 'FunctionName' => '#{method_name}',
48
- 'Class' => self.class.to_s.rpartition('::').last,
49
- 'Module' => self.class.to_s.rpartition('::').first,
50
- 'File' => '#{file}',
51
- 'LineNumber' => '#{line}'
52
- }
43
+ entry_kvs = {'Language' => 'ruby',
44
+ 'ProfileName' => '#{profile_name}',
45
+ 'FunctionName' => '#{method_name}',
46
+ 'Class' => self.class.to_s.rpartition('::').last,
47
+ 'Module' => self.class.to_s.rpartition('::').first,
48
+ 'File' => '#{file}',
49
+ 'LineNumber' => '#{line}'
50
+ }
53
51
 
54
- if #{store_args}
55
- entry_kvs['Args'] = pps *args
56
- end
52
+ if #{store_args}
53
+ entry_kvs['Args'] = pps *args
54
+ end
57
55
 
58
- Oboe::Context.log(nil, 'profile_entry', entry_kvs)
56
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
59
57
 
60
- ret = _oboe_orig_#{method_name}(*args, &block)
58
+ ret = _oboe_orig_#{method_name}(*args, &block)
61
59
 
62
- exit_kvs = {'Language' => 'ruby',
63
- 'ProfileName' => '#{profile_name}'
64
- }
65
-
66
- if #{store_return}
67
- exit_kvs['ReturnValue'] = pps ret
68
- end
60
+ exit_kvs = {'Language' => 'ruby',
61
+ 'ProfileName' => '#{profile_name}'
62
+ }
63
+
64
+ if #{store_return}
65
+ exit_kvs['ReturnValue'] = pps ret
66
+ end
69
67
 
70
- Oboe::Context.log(nil, 'profile_exit', exit_kvs)
68
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs)
71
69
 
72
- ret
73
- end"
74
- class_eval code, __FILE__, __LINE__
75
- alias_method "_oboe_orig_#{method_name}", method_name
76
- alias_method method_name, "_oboe_profiled_#{method_name}"
77
- end
70
+ ret
71
+ end"
72
+ class_eval code, __FILE__, __LINE__
73
+ alias_method "_oboe_orig_#{method_name}", method_name
74
+ alias_method method_name, "_oboe_profiled_#{method_name}"
78
75
  end
76
+ end
79
77
  end
@@ -10,10 +10,14 @@ begin
10
10
  require 'oboe_metal.so'
11
11
  require 'oboe_metal'
12
12
  end
13
- require 'rbconfig'
14
- require 'method_profiling'
15
13
  require 'oboe/config'
16
14
  require 'oboe/loading'
15
+ require 'method_profiling'
16
+ require 'oboe/instrumentation'
17
+ require 'oboe/ruby'
18
+
19
+ # Frameworks
20
+ require 'oboe/frameworks/rails' if defined?(::Rails)
17
21
 
18
22
  rescue LoadError
19
23
  puts "Unsupported Tracelytics environment (no libs). Going No-op."
@@ -6,11 +6,11 @@ module Oboe
6
6
  # layer.
7
7
  #
8
8
  def report_init(layer)
9
- platform_info = { '__Init' => 1 }
10
- platform_info['RubyPlatform'] = RUBY_PLATFORM
11
- platform_info['RubyVersion'] = RUBY_VERSION
12
- platform_info['RailsVersion'] = ::Rails.version if defined?(Rails)
13
- platform_info['OboeVersion'] = Gem.loaded_specs['oboe'].try(:version).to_s
9
+ platform_info = { '__Init' => 1 }
10
+ platform_info['RubyPlatformVersion'] = RUBY_PLATFORM
11
+ platform_info['RubyVersion'] = RUBY_VERSION
12
+ platform_info['RailsVersion'] = ::Rails.version if defined?(Rails)
13
+ platform_info['OboeRubyVersion'] = Gem.loaded_specs['oboe'].version if Gem.loaded_specs['oboe']
14
14
 
15
15
  force_trace do
16
16
  start_trace(layer, nil, platform_info) { }
@@ -40,11 +40,14 @@ module Oboe
40
40
  #
41
41
  # Returns nothing.
42
42
  def log_exception(layer, exn)
43
- log(layer, 'error', {
44
- :ErrorClass => exn.class.name,
45
- :Message => exn.message,
46
- :ErrorBacktrace => exn.backtrace.join("\r\n")
47
- })
43
+ unless exn.instance_variable_get(:@oboe_logged)
44
+ log(layer, 'error', {
45
+ :ErrorClass => exn.class.name,
46
+ :Message => exn.message,
47
+ :ErrorBacktrace => exn.backtrace.join("\r\n")
48
+ })
49
+ exn.instance_variable_set(:@oboe_logged, true)
50
+ end
48
51
  end
49
52
 
50
53
  # Public: Decide whether or not to start a trace, and report an event
@@ -35,7 +35,7 @@ module Oboe
35
35
  begin
36
36
  yield
37
37
  rescue Exception => e
38
- log_exception(layer, e)
38
+ log_exception(layer, e)
39
39
  raise
40
40
  ensure
41
41
  log_exit(layer, {}, protect_op)
@@ -78,7 +78,7 @@ module Oboe
78
78
  begin
79
79
  result = yield
80
80
  rescue Exception => e
81
- log_exception(layer, e)
81
+ log_exception(layer, e)
82
82
  e.instance_variable_set(:@xtrace, log_end(layer))
83
83
  raise
84
84
  end
@@ -8,9 +8,9 @@ module Oboe
8
8
  return unless Oboe::Config.has_key?(:rum_id)
9
9
  if Oboe::Config.tracing?
10
10
  if request.xhr?
11
- header_tmpl = File.read(File.dirname(__FILE__) + '/helpers/rum/rum_ajax_header.js.erb')
11
+ header_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_ajax_header.js.erb')
12
12
  else
13
- header_tmpl = File.read(File.dirname(__FILE__) + '/helpers/rum/rum_header.js.erb')
13
+ header_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_header.js.erb')
14
14
  end
15
15
  return raw(ERB.new(header_tmpl).result)
16
16
  end
@@ -26,7 +26,7 @@ module Oboe
26
26
  if Oboe::Config.tracing?
27
27
  # Even though the footer template is named xxxx.erb, there are no ERB tags in it so we'll
28
28
  # skip that step for now
29
- footer_tmpl = File.read(File.dirname(__FILE__) + '/helpers/rum/rum_footer.js.erb')
29
+ footer_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_footer.js.erb')
30
30
  return raw(footer_tmpl)
31
31
  end
32
32
  rescue Exception => e
@@ -55,7 +55,8 @@ module Oboe
55
55
 
56
56
 
57
57
  def self.load_instrumentation
58
- pattern = File.join(File.dirname(__FILE__), 'inst', '*.rb')
58
+ # Load the Rails specific instrumentation
59
+ pattern = File.join(File.dirname(__FILE__), 'rails/inst', '*.rb')
59
60
  Dir.glob(pattern) do |f|
60
61
  begin
61
62
  require f
@@ -63,6 +64,7 @@ module Oboe
63
64
  $stderr.puts "[oboe/loading] Error loading rails insrumentation file '#{f}' : #{e}"
64
65
  end
65
66
  end
67
+
66
68
  if ::Rails::VERSION::MAJOR > 2
67
69
  puts "Tracelytics oboe gem #{Gem.loaded_specs['oboe'].version.to_s} successfully loaded."
68
70
  else
@@ -88,6 +90,8 @@ module Oboe
88
90
  end # Oboe
89
91
 
90
92
  if defined?(::Rails)
93
+ require 'oboe/inst/rack'
94
+
91
95
  if ::Rails::VERSION::MAJOR > 2
92
96
  module Oboe
93
97
  class Railtie < ::Rails::Railtie
@@ -96,8 +100,14 @@ if defined?(::Rails)
96
100
  Oboe::Rails.include_helpers
97
101
  end
98
102
 
103
+ initializer 'oboe.rack' do |app|
104
+ puts "[oboe/loading] Instrumenting rack" if true or Oboe::Config[:verbose]
105
+ app.config.middleware.insert 0, "Oboe::Rack"
106
+ end
107
+
99
108
  config.after_initialize do
100
109
  Oboe::Loading.load_access_key
110
+ Oboe::Inst.load_instrumentation
101
111
  Oboe::Rails.load_instrumentation
102
112
  end
103
113
  end
@@ -105,8 +115,14 @@ if defined?(::Rails)
105
115
  else
106
116
  Oboe::Rails.load_initializer
107
117
  Oboe::Loading.load_access_key
118
+
119
+ puts "[oboe/loading] Instrumenting rack" if true or Oboe::Config[:verbose]
120
+ Rails.configuration.middleware.insert 0, "Oboe::Rack"
121
+
122
+ Oboe::Inst.load_instrumentation
108
123
  Oboe::Rails.load_instrumentation
109
- Oboe::Rails.include_helpers
124
+ Oboe::Rails.include_helpers
125
+
110
126
  end
111
127
  end
112
128
 
@@ -6,8 +6,7 @@ module Oboe
6
6
  module Rails3ActionController
7
7
  def process(*args)
8
8
 
9
- header = request.headers['X-Trace']
10
- Oboe::API.start_trace_with_target('rails', header, response.headers) do
9
+ Oboe::API.trace('rails', {}) do
11
10
  super
12
11
  end
13
12
  end
@@ -32,7 +31,7 @@ module Oboe
32
31
  end
33
32
 
34
33
  def render(*args)
35
- Oboe::API.trace('render', {}) do
34
+ Oboe::API.trace('actionview', {}) do
36
35
  super
37
36
  end
38
37
  end
@@ -57,8 +56,7 @@ if defined?(ActionController::Base)
57
56
  alias :render_without_oboe :render
58
57
 
59
58
  def process(*args)
60
- header = args[0].headers['X-Trace']
61
- Oboe::API.start_trace_with_target('rails', header, args[1].headers) do
59
+ Oboe::API.trace('rails', {}) do
62
60
  process_without_oboe(*args)
63
61
  end
64
62
  end
@@ -86,11 +84,11 @@ if defined?(ActionController::Base)
86
84
  end
87
85
 
88
86
  def render(options = nil, extra_options = {}, &block)
89
- Oboe::API.trace('render', {}) do
87
+ Oboe::API.trace('actionview', {}) do
90
88
  render_without_oboe(options, extra_options, &block)
91
89
  end
92
90
  end
93
91
  end
94
92
  end
95
- puts "[oboe/loading] Instrumenting ActionControler" if Oboe::Config[:verbose]
93
+ puts "[oboe/loading] Instrumenting actioncontroler" if Oboe::Config[:verbose]
96
94
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  if defined?(ActionView::Base)
5
5
  if Rails::VERSION::MAJOR == 3
6
- puts "[oboe/loading] Instrumenting ActionView"
6
+ puts "[oboe/loading] Instrumenting actionview"
7
7
 
8
8
  if Rails::VERSION::MINOR == 0
9
9
  ActionView::Partials::PartialRenderer.class_eval do
@@ -40,7 +40,7 @@ module Oboe
40
40
  if Oboe::Config.tracing? and !ignore_payload?(name)
41
41
 
42
42
  opts = extract_trace_details(sql, name)
43
- Oboe::API.trace('ActiveRecord', opts || {}) do
43
+ Oboe::API.trace('activerecord', opts || {}) do
44
44
  execute_without_oboe(sql, name)
45
45
  end
46
46
  else
@@ -52,7 +52,7 @@ module Oboe
52
52
  if Oboe::Config.tracing? and !ignore_payload?(name)
53
53
 
54
54
  opts = extract_trace_details(sql, name)
55
- Oboe::API.trace('ActiveRecord', opts || {}) do
55
+ Oboe::API.trace('activerecord', opts || {}) do
56
56
  exec_query_without_oboe(sql, name, binds)
57
57
  end
58
58
  else
@@ -64,7 +64,7 @@ module Oboe
64
64
  if Oboe::Config.tracing? and !ignore_payload?(name)
65
65
 
66
66
  opts = extract_trace_details(sql, name)
67
- Oboe::API.trace('ActiveRecord', opts || {}) do
67
+ Oboe::API.trace('activerecord', opts || {}) do
68
68
  exec_delete_without_oboe(sql, name, binds)
69
69
  end
70
70
  else
@@ -76,7 +76,7 @@ module Oboe
76
76
  if Oboe::Config.tracing? and !ignore_payload?(name)
77
77
 
78
78
  opts = extract_trace_details(sql, name)
79
- Oboe::API.trace('ActiveRecord', opts || {}) do
79
+ Oboe::API.trace('activerecord', opts || {}) do
80
80
  exec_insert_without_oboe(sql, name, binds)
81
81
  end
82
82
  else
@@ -89,7 +89,7 @@ module Oboe
89
89
  opts = {}
90
90
 
91
91
  opts[:Query] = "BEGIN"
92
- Oboe::API.trace('ActiveRecord', opts || {}) do
92
+ Oboe::API.trace('activerecord', opts || {}) do
93
93
  begin_db_transaction_without_oboe()
94
94
  end
95
95
  else
@@ -106,13 +106,13 @@ module Oboe
106
106
  if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :exec_query
107
107
  alias exec_query_without_oboe exec_query
108
108
  alias exec_query exec_query_with_oboe
109
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
109
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
110
110
  end
111
111
 
112
112
  if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :exec_delete
113
113
  alias exec_delete_without_oboe exec_delete
114
114
  alias exec_delete exec_delete_with_oboe
115
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
115
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
116
116
  end
117
117
  end
118
118
  end
@@ -126,7 +126,7 @@ module Oboe
126
126
  if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :execute
127
127
  alias execute_without_oboe execute
128
128
  alias execute execute_with_oboe
129
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
129
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
130
130
  end
131
131
  end
132
132
  end
@@ -140,7 +140,7 @@ module Oboe
140
140
  if ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::method_defined? :execute
141
141
  alias execute_without_oboe execute
142
142
  alias execute execute_with_oboe
143
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
143
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
144
144
  end
145
145
  end
146
146
  end
@@ -154,7 +154,7 @@ module Oboe
154
154
  if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_query
155
155
  alias exec_query_without_oboe exec_query
156
156
  alias exec_query exec_query_with_oboe
157
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
157
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
158
158
  end
159
159
  end
160
160
  end
@@ -168,14 +168,14 @@ module Oboe
168
168
  if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :execute
169
169
  alias execute_without_oboe execute
170
170
  alias execute execute_with_oboe
171
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
171
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
172
172
  end
173
173
 
174
174
  if ::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR == 1
175
175
  if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :begin_db_transaction
176
176
  alias begin_db_transaction_without_oboe begin_db_transaction
177
177
  alias begin_db_transaction begin_db_transaction_with_oboe
178
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
178
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
179
179
  end
180
180
  end
181
181
 
@@ -183,13 +183,13 @@ module Oboe
183
183
  if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_query
184
184
  alias exec_query_without_oboe exec_query
185
185
  alias exec_query exec_query_with_oboe
186
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
186
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
187
187
  end
188
188
 
189
189
  if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_delete
190
190
  alias exec_delete_without_oboe exec_delete
191
191
  alias exec_delete exec_delete_with_oboe
192
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
192
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
193
193
  end
194
194
  end
195
195
  end
@@ -205,13 +205,13 @@ module Oboe
205
205
  if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :execute
206
206
  alias execute_without_oboe execute
207
207
  alias execute execute_with_oboe
208
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
208
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
209
209
  end
210
210
  else
211
211
  if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :exec_insert
212
212
  alias exec_insert_without_oboe exec_insert
213
213
  alias exec_insert exec_insert_with_oboe
214
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
214
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
215
215
  end
216
216
 
217
217
  # In Rails 3.1, exec_query was defined as a private method
@@ -219,13 +219,13 @@ module Oboe
219
219
  ActiveRecord::ConnectionAdapters::Mysql2Adapter::private_method_defined? :exec_query
220
220
  alias exec_query_without_oboe exec_query
221
221
  alias exec_query exec_query_with_oboe
222
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
222
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
223
223
  end
224
224
 
225
225
  if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :exec_delete
226
226
  alias exec_delete_without_oboe exec_delete
227
227
  alias exec_delete exec_delete_with_oboe
228
- else puts "[oboe/loading] Couldn't properly instrument ActiveRecord layer. Partial traces may occur."
228
+ else puts "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
229
229
  end
230
230
  end
231
231
  end
@@ -235,50 +235,51 @@ module Oboe
235
235
  module FlavorInitializers
236
236
  def self.mysql
237
237
  if ActiveRecord::Base::connection.adapter_name.downcase.to_sym == :mysql
238
- puts "[oboe/loading] Instrumenting ActiveRecord MysqlAdapter" if Oboe::Config[:verbose]
238
+ puts "[oboe/loading] Instrumenting activerecord mysqladapter" if Oboe::Config[:verbose]
239
239
  if ::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR > 1
240
- ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.module_eval do
240
+ ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.module_eval do
241
241
  include Oboe::Inst::ConnectionAdapters::AbstractMysqlAdapter
242
- end
243
- ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
242
+ end if defined?(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter)
243
+
244
+ ::ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
244
245
  include Oboe::Inst::ConnectionAdapters::MysqlAdapter
245
- end
246
+ end if defined?(::ActiveRecord::ConnectionAdapters::MysqlAdapter)
246
247
  else
247
- ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
248
+ ::ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
248
249
  include Oboe::Inst::ConnectionAdapters::LegacyMysqlAdapter
249
- end
250
+ end if defined?(::ActiveRecord::ConnectionAdapters::MysqlAdapter)
250
251
  end
251
252
  end
252
253
  end
253
254
 
254
255
  def self.mysql2
255
256
  if ActiveRecord::Base::connection.adapter_name.downcase.to_sym == :mysql2
256
- puts "[oboe/loading] Instrumenting ActiveRecord Mysql2Adapter" if Oboe::Config[:verbose]
257
- ActiveRecord::ConnectionAdapters::Mysql2Adapter.module_eval do
257
+ puts "[oboe/loading] Instrumenting activerecord mysql2adapter" if Oboe::Config[:verbose]
258
+ ::ActiveRecord::ConnectionAdapters::Mysql2Adapter.module_eval do
258
259
  include Oboe::Inst::ConnectionAdapters::Mysql2Adapter
259
- end
260
+ end if defined?(::ActiveRecord::ConnectionAdapters::Mysql2Adapter)
260
261
  end
261
262
  end
262
263
 
263
264
  def self.postgresql
264
265
  if ActiveRecord::Base::connection.adapter_name.downcase.to_sym == :postgresql
265
- puts "[oboe/loading] Instrumenting ActiveRecord PostgreSQLAdapter" if Oboe::Config[:verbose]
266
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.module_eval do
266
+ puts "[oboe/loading] Instrumenting activerecord postgresqladapter" if Oboe::Config[:verbose]
267
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.module_eval do
267
268
  if ::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR > 0
268
269
  include Oboe::Inst::ConnectionAdapters::PostgreSQLAdapter
269
270
  else
270
271
  include Oboe::Inst::ConnectionAdapters::LegacyPostgreSQLAdapter
271
272
  end
272
- end
273
+ end if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
273
274
  end
274
275
  end
275
276
 
276
277
  def self.oracle
277
278
  if ActiveRecord::Base::connection.adapter_name.downcase.to_sym == :oracleenhanced
278
- puts "[oboe/loading] Instrumenting ActiveRecord OracleEnhancedAdapter" if Oboe::Config[:verbose]
279
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.module_eval do
279
+ puts "[oboe/loading] Instrumenting activerecord oracleenhancedadapter" if Oboe::Config[:verbose]
280
+ ::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.module_eval do
280
281
  include Oboe::Inst::ConnectionAdapters
281
- end
282
+ end if defined?(::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter)
282
283
  end
283
284
  end
284
285
  end
@@ -15,6 +15,8 @@ module Oboe
15
15
  # Open issue - how to handle multiple Cassandra servers
16
16
  report_kvs[:RemoteHost], report_kvs[:RemotePort] = @servers.first.split(":")
17
17
 
18
+ report_kvs[:Backtrace] = Oboe::API.backtrace
19
+
18
20
  if options.empty? and args.is_a?(Array)
19
21
  options = args.last if args.last.is_a?(Hash)
20
22
  end
@@ -283,7 +285,7 @@ module Oboe
283
285
  end
284
286
 
285
287
  if defined?(::Cassandra)
286
- puts "[oboe/loading] Instrumenting Cassandra"
288
+ puts "[oboe/loading] Instrumenting cassandra"
287
289
  class ::Cassandra
288
290
  include Oboe::Inst::Cassandra
289
291
 
@@ -8,7 +8,7 @@ module Oboe
8
8
 
9
9
  def self.included(cls)
10
10
  cls.class_eval do
11
- puts "[oboe/loading] Instrumenting Memcache (Dalli)" if Oboe::Config[:verbose]
11
+ puts "[oboe/loading] Instrumenting memcache (dalli)" if Oboe::Config[:verbose]
12
12
  if ::Dalli::Client.private_method_defined? :perform
13
13
  alias perform_without_oboe perform
14
14
  alias perform perform_with_oboe
@@ -13,16 +13,17 @@ Net::HTTP.class_eval do
13
13
  opts = {}
14
14
  if args.length and args[0]
15
15
  req = args[0]
16
- req['X-Trace'] = Oboe::Context.toString()
17
16
 
18
17
  opts['IsService'] = 1
19
18
  opts['RemoteProtocol'] = use_ssl? ? 'HTTPS' : 'HTTP'
20
19
  opts['RemoteHost'] = addr_port
21
20
  opts['ServiceArg'] = req.path
22
21
  opts['Method'] = req.method
22
+
23
+ Oboe::API.log('net-http', 'info', opts)
24
+ req['X-Trace'] = Oboe::Context.toString()
23
25
  end
24
26
 
25
- Oboe::API.log('net-http', 'info', opts)
26
27
  resp = request_without_oboe(*args, &block)
27
28
 
28
29
  xtrace = resp.get_fields('X-Trace')
@@ -41,6 +41,8 @@ if defined?(::Mongo::DB)
41
41
 
42
42
  report_kvs[:New_Collection_Name] = args[0] if m == :create_collection
43
43
  report_kvs[:Collection_Name] = args[0] if m == :drop_collection
44
+
45
+ report_kvs[:Backtrace] = Oboe::API.backtrace
44
46
  rescue
45
47
  logger.warn "[oboe/error] Problem processing mongo args (#{m})" if defined?(logger)
46
48
  end
@@ -113,6 +115,8 @@ if defined?(::Mongo::Collection)
113
115
  report_kvs[:RemoteHost] = @db.connection.host
114
116
  report_kvs[:RemotePort] = @db.connection.port
115
117
  report_kvs[:Collection] = @name
118
+
119
+ report_kvs[:Backtrace] = Oboe::API.backtrace
116
120
 
117
121
  report_kvs[:QueryOp] = m
118
122
  report_kvs[:Query] = args[0].try(:to_json) if args and not args.empty? and args[0].class == Hash
@@ -0,0 +1,32 @@
1
+ # Copyright (c) 2012 by Tracelytics, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'rack'
5
+
6
+ module Oboe
7
+ class Rack
8
+ attr_reader :app
9
+
10
+ def initialize(app)
11
+ @app = app
12
+ end
13
+
14
+ def call(env)
15
+ xtrace = env['HTTP_X_TRACE']
16
+
17
+ report_kvs = {}
18
+ report_kvs[:SampleRate] = Oboe::Config[:sample_rate]
19
+
20
+ response, xtrace = Oboe::API.start_trace('rack', xtrace, report_kvs) do
21
+ @app.call(env)
22
+ end
23
+ rescue Exception => e
24
+ xtrace = e.instance_variable_get(:@xtrace)
25
+ raise
26
+ ensure
27
+ response[1].merge!({'X-Trace' => xtrace}) if xtrace
28
+ return response
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,15 @@
1
+ module Oboe
2
+ module Inst
3
+ def self.load_instrumentation
4
+ # Load the general instrumentation
5
+ pattern = File.join(File.dirname(__FILE__), 'inst', '*.rb')
6
+ Dir.glob(pattern) do |f|
7
+ begin
8
+ require f
9
+ rescue => e
10
+ $stderr.puts "[oboe/loading] Error loading insrumentation file '#{f}' : #{e}"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Oboe
2
+ module Ruby
3
+ def self.initialize
4
+ Oboe::API.report_init('ruby')
5
+ Oboe::Loading.load_access_key
6
+ Oboe::Inst.load_instrumentation
7
+ end
8
+ end
9
+ end
@@ -2,8 +2,8 @@ module Oboe
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- PATCH = 8
6
- BUILD = nil
5
+ PATCH = 9
6
+ BUILD = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,55 +1,66 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: oboe
3
- version: !ruby/object:Gem::Version
4
- version: 1.3.8
3
+ version: !ruby/object:Gem::Version
4
+ hash: 97
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 9
10
+ - 1
11
+ version: 1.3.9.1
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - Tracelytics, Inc.
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
18
+
19
+ date: 2013-01-29 00:00:00 Z
13
20
  dependencies: []
21
+
14
22
  description: The oboe gem provides AppNeta instrumentation for Ruby and Ruby frameworks.
15
23
  email: contact@tracelytics.com
16
24
  executables: []
17
- extensions:
25
+
26
+ extensions:
18
27
  - ext/oboe_metal/extconf.rb
19
- extra_rdoc_files:
28
+ extra_rdoc_files:
20
29
  - LICENSE
21
- files:
22
- - lib/oboe_metal.rb
23
- - lib/joboe_metal.rb
30
+ files:
24
31
  - lib/oboe.rb
25
- - lib/oboe/loading.rb
32
+ - lib/oboe_fu.rb
33
+ - lib/method_profiling.rb
34
+ - lib/joboe_metal.rb
35
+ - lib/oboe_metal.rb
36
+ - lib/oboe/config.rb
37
+ - lib/oboe/version.rb
26
38
  - lib/oboe/api.rb
27
- - lib/oboe/api/memcache.rb
28
- - lib/oboe/api/layerinit.rb
29
- - lib/oboe/api/util.rb
39
+ - lib/oboe/loading.rb
40
+ - lib/oboe/ruby.rb
41
+ - lib/oboe/inst/cassandra.rb
42
+ - lib/oboe/inst/dalli.rb
43
+ - lib/oboe/inst/rack.rb
44
+ - lib/oboe/inst/mongo.rb
45
+ - lib/oboe/inst/memcached.rb
46
+ - lib/oboe/inst/moped.rb
47
+ - lib/oboe/inst/http.rb
48
+ - lib/oboe/inst/memcache.rb
30
49
  - lib/oboe/api/logging.rb
50
+ - lib/oboe/api/layerinit.rb
31
51
  - lib/oboe/api/tracing.rb
32
- - lib/oboe/version.rb
33
- - lib/oboe/config.rb
34
- - lib/oboe/frameworks/rails/inst/memcache.rb
35
- - lib/oboe/frameworks/rails/inst/mongo.rb
36
- - lib/oboe/frameworks/rails/inst/http.rb
37
- - lib/oboe/frameworks/rails/inst/rack.rb
38
- - lib/oboe/frameworks/rails/inst/action_controller.rb
39
- - lib/oboe/frameworks/rails/inst/moped.rb
40
- - lib/oboe/frameworks/rails/inst/dalli.rb
52
+ - lib/oboe/api/util.rb
53
+ - lib/oboe/api/memcache.rb
54
+ - lib/oboe/frameworks/rails.rb
41
55
  - lib/oboe/frameworks/rails/inst/active_record.rb
56
+ - lib/oboe/frameworks/rails/inst/action_controller.rb
42
57
  - lib/oboe/frameworks/rails/inst/action_view.rb
43
- - lib/oboe/frameworks/rails/inst/cassandra.rb
44
- - lib/oboe/frameworks/rails/inst/memcached.rb
45
- - lib/oboe/frameworks/rails/rails.rb
46
- - lib/method_profiling.rb
47
- - lib/oboe_fu.rb
48
- - lib/rails/generators/oboe/install_generator.rb
58
+ - lib/oboe/instrumentation.rb
49
59
  - lib/rails/generators/oboe/templates/oboe_initializer.rb
50
- - lib/oboe/frameworks/rails/helpers/rum/rum_footer.js.erb
51
- - lib/oboe/frameworks/rails/helpers/rum/rum_ajax_header.js.erb
60
+ - lib/rails/generators/oboe/install_generator.rb
52
61
  - lib/oboe/frameworks/rails/helpers/rum/rum_header.js.erb
62
+ - lib/oboe/frameworks/rails/helpers/rum/rum_ajax_header.js.erb
63
+ - lib/oboe/frameworks/rails/helpers/rum/rum_footer.js.erb
53
64
  - ext/oboe_metal/noop/noop.c
54
65
  - ext/oboe_metal/src/oboe_wrap.cxx
55
66
  - ext/oboe_metal/src/oboe.hpp
@@ -59,26 +70,36 @@ files:
59
70
  - ext/oboe_metal/extconf.rb
60
71
  homepage: http://tracelytics.com
61
72
  licenses: []
73
+
62
74
  post_install_message:
63
75
  rdoc_options: []
64
- require_paths:
76
+
77
+ require_paths:
65
78
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
67
80
  none: false
68
- requirements:
69
- - - ! '>='
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
89
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
78
97
  requirements: []
98
+
79
99
  rubyforge_project:
80
- rubygems_version: 1.8.11
100
+ rubygems_version: 1.8.15
81
101
  signing_key:
82
102
  specification_version: 3
83
103
  summary: Tracelytics instrumentation gem
84
104
  test_files: []
105
+
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2012 by Tracelytics, Inc.
2
- # All rights reserved.
3
-
4
- module Oboe
5
- class Middleware
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- header = env['HTTP_X_TRACE']
12
- result, header = Oboe::API.start_trace('rack', header) do
13
- env['HTTP_X_TRACE'] = Oboe::Context.toString()
14
- @app.call(env)
15
- end
16
- result
17
- rescue Exception => e
18
- header = e.instance_variable_get(:@xtrace)
19
- raise
20
- ensure
21
- env['HTTP_X_TRACE'] = header if header
22
- end
23
- end
24
- end
25
-
26
- if false and defined?(::Rails.configuration.middleware)
27
- puts "[oboe/loading] Instrumenting rack" if Oboe::Config[:verbose]
28
- ::Rails.configuration.middleware.insert 0, Oboe::Middleware
29
- end