oboe 1.3.5 → 1.3.6

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.
@@ -13,7 +13,7 @@ module Oboe
13
13
  end
14
14
 
15
15
  def process_action(*args)
16
- opts = {
16
+ report_kvs = {
17
17
  'HTTP-Host' => @_request.headers['HTTP_HOST'],
18
18
  :URL => @_request.headers['REQUEST_URI'],
19
19
  :Method => @_request.headers['REQUEST_METHOD'],
@@ -22,12 +22,12 @@ module Oboe
22
22
  }
23
23
  super
24
24
 
25
- opts[:Status] = @_response.status
26
- Oboe::API.log('rails', 'info', opts)
25
+ report_kvs[:Status] = @_response.status
26
+ Oboe::API.log('rails', 'info', report_kvs)
27
27
 
28
28
  rescue Exception => exception
29
- opts[:Status] = 500
30
- Oboe::API.log('rails', 'info', opts)
29
+ report_kvs[:Status] = 500
30
+ Oboe::API.log('rails', 'info', report_kvs)
31
31
  raise
32
32
  end
33
33
 
@@ -54,6 +54,7 @@ if defined?(ActionController::Base)
54
54
  alias :perform_action_without_oboe :perform_action
55
55
  alias :rescue_action_without_oboe :rescue_action
56
56
  alias :process_without_oboe :process
57
+ alias :render_without_oboe :render
57
58
 
58
59
  def process(*args)
59
60
  header = args[0].headers['X-Trace']
@@ -63,25 +64,33 @@ if defined?(ActionController::Base)
63
64
  end
64
65
 
65
66
  def perform_action(*arguments)
66
- opts = {
67
+ report_kvs = {
67
68
  'HTTP-Host' => @_request.headers['HTTP_HOST'],
68
69
  :URL => @_request.headers['REQUEST_URI'],
69
70
  :Method => @_request.headers['REQUEST_METHOD'],
70
- :Status => @_response.status,
71
- 'Controller' => @_request.path_parameters['controller'],
72
- 'Action' => @_request.path_parameters['action']
71
+ :Controller => @_request.path_parameters['controller'],
72
+ :Action => @_request.path_parameters['action']
73
73
  }
74
74
 
75
- Oboe::API.log('rails', 'info', opts)
76
75
  perform_action_without_oboe(*arguments)
76
+ begin
77
+ report_kvs[:Status] = @_response.status.to_i
78
+ rescue
79
+ end
80
+ Oboe::API.log('rails', 'info', report_kvs)
77
81
  end
78
82
 
79
83
  def rescue_action(exn)
80
84
  Oboe::API.log_exception('rails', exn)
81
85
  rescue_action_without_oboe(exn)
82
86
  end
87
+
88
+ def render(options = nil, extra_options = {}, &block)
89
+ Oboe::API.trace('render', {}) do
90
+ render_without_oboe(options, extra_options, &block)
91
+ end
92
+ end
83
93
  end
84
94
  end
85
95
  puts "[oboe/loading] Instrumenting ActionControler" if Oboe::Config[:verbose]
86
96
  end
87
- # vim:set expandtab:tabstop=2
@@ -0,0 +1,191 @@
1
+ # Copyright (c) 2012 by Tracelytics, Inc.
2
+ # All rights reserved.
3
+
4
+ if defined?(ActionView::Base)
5
+ if Rails::VERSION::MAJOR == 3
6
+ puts "[oboe/loading] Instrumenting ActionView"
7
+
8
+ if Rails::VERSION::MINOR == 0
9
+ ActionView::Partials::PartialRenderer.class_eval do
10
+ alias :render_partial_without_oboe :render_partial
11
+ def render_partial(object = @object)
12
+ entry_kvs = {}
13
+ begin
14
+ entry_kvs[:Language] = :ruby
15
+ entry_kvs[:ProfileName] = @options[:partial] if @options.is_a?(Hash)
16
+ entry_kvs[:FunctionName] = :render_partial
17
+ entry_kvs[:Class] = :PartialRenderer
18
+ entry_kvs[:Module] = 'ActionView::Partials'
19
+ entry_kvs[:File] = __FILE__
20
+ entry_kvs[:LineNumber] = __LINE__
21
+ rescue
22
+ end
23
+
24
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
25
+ ret = render_partial_without_oboe(object)
26
+
27
+ exit_kvs = {}
28
+ begin
29
+ exit_kvs[:Language] = :ruby
30
+ exit_kvs[:ProfileName] = @options[:partial] if @options.is_a?(Hash)
31
+ rescue
32
+ end
33
+
34
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
35
+ ret
36
+ end
37
+
38
+ alias :render_collection_without_oboe :render_collection
39
+ def render_collection
40
+ entry_kvs = {}
41
+ begin
42
+ entry_kvs[:Language] = :ruby
43
+ entry_kvs[:ProfileName] = @path
44
+ entry_kvs[:FunctionName] = :render_collection
45
+ entry_kvs[:Class] = :PartialRenderer
46
+ entry_kvs[:Module] = 'ActionView::Partials'
47
+ entry_kvs[:File] = __FILE__
48
+ entry_kvs[:LineNumber] = __LINE__
49
+ rescue
50
+ end
51
+
52
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
53
+ ret = render_collection_without_oboe
54
+
55
+ exit_kvs = {}
56
+ begin
57
+ exit_kvs[:Language] = :ruby
58
+ exit_kvs[:ProfileName] = @path
59
+ rescue
60
+ end
61
+
62
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
63
+ ret
64
+ end
65
+ end
66
+ else
67
+ ActionView::PartialRenderer.class_eval do
68
+ alias :render_partial_without_oboe :render_partial
69
+ def render_partial
70
+ entry_kvs = {}
71
+ begin
72
+ entry_kvs[:Language] = :ruby
73
+ entry_kvs[:ProfileName] = @options[:partial] if @options.is_a?(Hash)
74
+ entry_kvs[:FunctionName] = :render_partial
75
+ entry_kvs[:Class] = :PartialRenderer
76
+ entry_kvs[:Module] = :ActionView
77
+ entry_kvs[:File] = __FILE__
78
+ entry_kvs[:LineNumber] = __LINE__
79
+ rescue
80
+ end
81
+
82
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
83
+ ret = render_partial_without_oboe
84
+
85
+ exit_kvs = {}
86
+ begin
87
+ exit_kvs[:Language] = :ruby
88
+ exit_kvs[:ProfileName] = @options[:partial] if @options.is_a?(Hash)
89
+ rescue
90
+ end
91
+
92
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
93
+ ret
94
+ end
95
+
96
+ alias :render_collection_without_oboe :render_collection
97
+ def render_collection
98
+ entry_kvs = {}
99
+ begin
100
+ entry_kvs[:Language] = :ruby
101
+ entry_kvs[:ProfileName] = @path
102
+ entry_kvs[:FunctionName] = :render_collection
103
+ entry_kvs[:Class] = :PartialRenderer
104
+ entry_kvs[:Module] = :ActionView
105
+ entry_kvs[:File] = __FILE__
106
+ entry_kvs[:LineNumber] = __LINE__
107
+ rescue
108
+ end
109
+
110
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
111
+ ret = render_collection_without_oboe
112
+
113
+ exit_kvs = {}
114
+ begin
115
+ exit_kvs[:Language] = :ruby
116
+ exit_kvs[:ProfileName] = @path
117
+ rescue
118
+ end
119
+
120
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
121
+ ret
122
+ end
123
+ end
124
+ end
125
+ elsif Rails::VERSION::MAJOR == 2
126
+ puts "[oboe/loading] Instrumenting ActionView"
127
+
128
+ ActionView::Partials.module_eval do
129
+ alias :render_partial_without_oboe :render_partial
130
+ def render_partial(options = {})
131
+ if options.has_key?(:partial) and options[:partial].is_a?(String)
132
+ entry_kvs = {}
133
+ begin
134
+ entry_kvs[:Language] = :ruby
135
+ entry_kvs[:ProfileName] = options[:partial]
136
+ entry_kvs[:FunctionName] = :render_partial
137
+ entry_kvs[:Class] = :Partials
138
+ entry_kvs[:Module] = :ActionView
139
+ entry_kvs[:File] = __FILE__
140
+ entry_kvs[:LineNumber] = __LINE__
141
+ rescue
142
+ end
143
+
144
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
145
+ ret = render_partial_without_oboe(options)
146
+
147
+ exit_kvs = {}
148
+ begin
149
+ exit_kvs[:Language] = :ruby
150
+ exit_kvs[:ProfileName] = options[:partial]
151
+ rescue
152
+ end
153
+
154
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
155
+ else
156
+ ret = render_partial_without_oboe(options)
157
+ end
158
+ ret
159
+ end
160
+
161
+ alias :render_partial_collection_without_oboe :render_partial_collection
162
+ def render_partial_collection(options = {})
163
+ entry_kvs = {}
164
+ begin
165
+ entry_kvs[:Language] = :ruby
166
+ entry_kvs[:ProfileName] = :collection
167
+ entry_kvs[:FunctionName] = :render_partial_collection
168
+ entry_kvs[:Class] = :Partials
169
+ entry_kvs[:Module] = :ActionView
170
+ entry_kvs[:File] = __FILE__
171
+ entry_kvs[:LineNumber] = __LINE__
172
+ rescue
173
+ end
174
+
175
+ Oboe::Context.log(nil, 'profile_entry', entry_kvs)
176
+ ret = render_partial_collection_without_oboe(options)
177
+
178
+ exit_kvs = {}
179
+ begin
180
+ exit_kvs[:Language] = :ruby
181
+ exit_kvs[:ProfileName] = :collection
182
+ rescue
183
+ end
184
+
185
+ Oboe::Context.log(nil, 'profile_exit', exit_kvs, false)
186
+ ret
187
+ end
188
+ end
189
+ end
190
+ end
191
+ # vim:set expandtab:tabstop=2
@@ -9,7 +9,7 @@ module Oboe
9
9
 
10
10
  begin
11
11
  report_kvs[:Op] = op.to_s
12
- report_kvs[:Cf] = column_family.to_s
12
+ report_kvs[:Cf] = column_family.to_s if column_family
13
13
  report_kvs[:Key] = keys.to_s if keys
14
14
 
15
15
  # Open issue - how to handle multiple Cassandra servers
@@ -193,9 +193,12 @@ module Oboe
193
193
  def create_index_with_oboe(keyspace, column_family, column_name, validation_class)
194
194
  if Oboe::Config.tracing?
195
195
  report_kvs = extract_trace_details(:create_index, column_family, nil, nil)
196
- report_kvs[:Keyspace] = keyspace.to_s
197
- report_kvs[:Column_name] = column_name.to_s
198
- report_kvs[:Validation_class] = validation_class.to_s
196
+ begin
197
+ report_kvs[:Keyspace] = keyspace.to_s
198
+ report_kvs[:Column_name] = column_name.to_s
199
+ report_kvs[:Validation_class] = validation_class.to_s
200
+ rescue
201
+ end
199
202
 
200
203
  Oboe::API.trace('cassandra', report_kvs) do
201
204
  create_index_without_oboe(keyspace, column_family, column_name, validation_class)
@@ -208,8 +211,11 @@ module Oboe
208
211
  def drop_index_with_oboe(keyspace, column_family, column_name)
209
212
  if Oboe::Config.tracing?
210
213
  report_kvs = extract_trace_details(:drop_index, column_family, nil, nil)
211
- report_kvs[:Keyspace] = keyspace.to_s
212
- report_kvs[:Column_name] = column_name.to_s
214
+ begin
215
+ report_kvs[:Keyspace] = keyspace.to_s
216
+ report_kvs[:Column_name] = column_name.to_s
217
+ rescue
218
+ end
213
219
 
214
220
  Oboe::API.trace('cassandra', report_kvs) do
215
221
  drop_index_without_oboe(keyspace, column_family, column_name)
@@ -222,7 +228,10 @@ module Oboe
222
228
  def add_column_family_with_oboe(cf_def)
223
229
  if Oboe::Config.tracing?
224
230
  report_kvs = extract_trace_details(:add_column_family, nil, nil, nil)
225
- report_kvs[:Name] = cf_def[:name] if cf_def.is_a?(Hash) and cf_def.has_key?(:name)
231
+ begin
232
+ report_kvs[:Cf] = cf_def[:name] if cf_def.is_a?(Hash) and cf_def.has_key?(:name)
233
+ rescue
234
+ end
226
235
 
227
236
  Oboe::API.trace('cassandra', report_kvs) do
228
237
  add_column_family_without_oboe(cf_def)
@@ -247,7 +256,7 @@ module Oboe
247
256
  def add_keyspace_with_oboe(ks_def)
248
257
  if Oboe::Config.tracing?
249
258
  report_kvs = extract_trace_details(:add_keyspace, nil, nil, nil)
250
- report_kvs[:Name] = ks_def[:name] if ks_def.is_a?(Hash) and ks_def.has_key?(:name)
259
+ report_kvs[:Name] = ks_def.name rescue ""
251
260
 
252
261
  Oboe::API.trace('cassandra', report_kvs) do
253
262
  add_keyspace_without_oboe(ks_def)
@@ -260,7 +269,7 @@ module Oboe
260
269
  def drop_keyspace_with_oboe(keyspace)
261
270
  if Oboe::Config.tracing?
262
271
  report_kvs = extract_trace_details(:drop_keyspace, nil, nil, nil)
263
- report_kvs[:Name] = keyspace.to_s
272
+ report_kvs[:Name] = keyspace.to_s rescue ""
264
273
 
265
274
  Oboe::API.trace('cassandra', report_kvs) do
266
275
  drop_keyspace_without_oboe(keyspace)
@@ -81,7 +81,7 @@ if defined?(::Mongo::Cursor)
81
81
  else
82
82
  report_kvs[:Query] = 'all'
83
83
  end
84
- report_kvs[:limit] = @limit if @limit != 0
84
+ report_kvs[:Limit] = @limit if @limit != 0
85
85
  end
86
86
 
87
87
  rescue
@@ -133,7 +133,7 @@ if defined?(::Mongo::Collection)
133
133
  if m == :map_reduce
134
134
  report_kvs[:Map_Function] = args[0]
135
135
  report_kvs[:Reduce_Function] = args[1]
136
- report_kvs[:limit] = args[2][:limit] if args[2] and args[2].has_key?(:limit)
136
+ report_kvs[:Limit] = args[2][:limit] if args[2] and args[2].has_key?(:limit)
137
137
  end
138
138
 
139
139
  report_kvs[:New_Collection_Name] = args[0] if m == :rename
@@ -165,12 +165,12 @@ if defined?(::Mongo::Collection)
165
165
  args_length = args.length
166
166
 
167
167
  if m == :distinct and args_length >= 2
168
- report_kvs[:key] = args[0]
168
+ report_kvs[:Key] = args[0]
169
169
  report_kvs[:Query] = args[1].try(:to_json) if args[1] and args[1].class == Hash
170
170
  end
171
171
 
172
172
  if m == :find and args_length > 0
173
- report_kvs[:limit] = args[0][:limit] if !args[0].nil? and args[0].has_key?(:limit)
173
+ report_kvs[:Limit] = args[0][:limit] if !args[0].nil? and args[0].has_key?(:limit)
174
174
  end
175
175
 
176
176
  if m == :group
@@ -2,7 +2,7 @@ module Oboe
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- PATCH = 5
5
+ PATCH = 6
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Oboe_metal
5
5
  class Context
6
- def self.log(layer, label, options = {})
6
+ def self.log(layer, label, options = {}, with_backtrace = true)
7
7
  evt = Oboe::Context.createEvent()
8
8
  evt.addInfo("Layer", layer.to_s)
9
9
  evt.addInfo("Label", label.to_s)
@@ -12,7 +12,7 @@ module Oboe_metal
12
12
  evt.addInfo(k.to_s, v.to_s)
13
13
  end
14
14
 
15
- evt.addInfo("Backtrace", Kernel.caller.join("\r\n"))
15
+ evt.addInfo("Backtrace", Kernel.caller.join("\r\n")) if with_backtrace
16
16
 
17
17
  Oboe.reporter.sendReport(evt)
18
18
  end
@@ -0,0 +1,68 @@
1
+
2
+ module Oboe
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.join(File.dirname(__FILE__), 'templates')
5
+ desc "Copies an oboe initializer files to your application."
6
+
7
+ def copy_initializer
8
+ # Set defaults
9
+ @tracing_mode = 'through'
10
+ @sampling_rate = '300000'
11
+ @verbose = 'false'
12
+
13
+ say ""
14
+ say set_color "Welcome to the Tracelytics Ruby instrumentation setup.", :green, :bold
15
+ say ""
16
+ say "To instrument your Rails application, you have the option to setup sampling strategies here."
17
+ say ""
18
+ say "More information on instrumenting Ruby applications can be found here:"
19
+ say "http://support.tracelytics.com/kb/ruby/instrumenting-ruby-apps"
20
+ while true do
21
+ say ""
22
+ say set_color "Tracing Mode", :green
23
+ say "------------"
24
+ say "When traces should be initiated for incoming requests. Valid options are 'always',"
25
+ say "'through' (when the request is initiated with a tracing header from upstream) and 'never'."
26
+ say "You must set this directive to 'always' in order to initiate tracing."
27
+ say ""
28
+ user_tracing_mode = ask set_color "* Tracing Mode? [through]:", :yellow
29
+ user_tracing_mode.downcase!
30
+
31
+ break if user_tracing_mode.blank?
32
+ valid = ['always', 'through', 'never'].include?(user_tracing_mode)
33
+ say set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
34
+ if valid
35
+ @tracing_mode = user_tracing_mode
36
+ break
37
+ end
38
+ end
39
+
40
+ if @tracing_mode == "always"
41
+ while true do
42
+ say ""
43
+ say set_color "Sampling Rate", :green
44
+ say "-------------"
45
+ say "This value reflects the number of requests out of every million that will be traced, and must be an integer between 0 and 1000000. Default is 300000 (30%)."
46
+ say ""
47
+ user_sampling_rate = ask set_color "* Sampling Rate? [300000]:", :yellow
48
+ break if user_sampling_rate.blank?
49
+
50
+ valid = user_sampling_rate.to_i.between?(1, 1000000)
51
+ say set_color "Sampling Rate must be a number between 1 and 1000000", :red, :bold unless valid
52
+ if valid
53
+ @sampling_rate = user_sampling_rate.to_i
54
+ break
55
+ end
56
+ end
57
+ end
58
+
59
+ say ""
60
+ say "You can change these values in the future by modifying config/initializers/oboe.rb"
61
+ say ""
62
+ say "Thanks! Creating initialization file..."
63
+ say ""
64
+
65
+ template "oboe_initializer.rb", "config/initializers/oboe.rb"
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,16 @@
1
+ if defined?(::Oboe::Config)
2
+ # When traces should be initiated for incoming requests. Valid options are 'always',
3
+ # 'through' (when the request is initiated with a tracing header from upstream) and 'never'.
4
+ # You must set this directive to 'always' in order to initiate tracing when there
5
+ # is no front-end webserver initiating traces.
6
+ Oboe::Config[:tracing_mode] = '<%= @tracing_mode %>'
7
+ <% if ['through', 'never'].include?(@tracing_mode) %>
8
+ # sample_rate is a value from 0 - 1m indicating the fraction of requests per million to trace
9
+ # Oboe::Config[:sample_rate] = <%= @sampling_rate %>
10
+ <% else %>
11
+ # sample_rate is a value from 0 - 1m indicating the fraction of requests per million to trace
12
+ Oboe::Config[:sample_rate] = <%= @sampling_rate %>
13
+ <% end %>
14
+ # Verbose output of instrumentation initialization
15
+ # Oboe::Config[:verbose] = <%= @verbose %>
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oboe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -37,10 +37,13 @@ files:
37
37
  - lib/oboe/frameworks/rails/inst/action_controller.rb
38
38
  - lib/oboe/frameworks/rails/inst/dalli.rb
39
39
  - lib/oboe/frameworks/rails/inst/active_record.rb
40
+ - lib/oboe/frameworks/rails/inst/action_view.rb
40
41
  - lib/oboe/frameworks/rails/inst/cassandra.rb
41
42
  - lib/oboe/frameworks/rails/inst/memcached.rb
42
43
  - lib/oboe/frameworks/rails/rails.rb
43
44
  - lib/oboe_fu.rb
45
+ - lib/rails/generators/oboe/install_generator.rb
46
+ - lib/rails/generators/oboe/templates/oboe_initializer.rb
44
47
  - lib/oboe/frameworks/rails/helpers/rum/rum_footer.js.erb
45
48
  - lib/oboe/frameworks/rails/helpers/rum/rum_ajax_header.js.erb
46
49
  - lib/oboe/frameworks/rails/helpers/rum/rum_header.js.erb