traceview 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +5 -0
  4. data/.travis.yml +58 -0
  5. data/Appraisals +10 -0
  6. data/CHANGELOG.md +490 -0
  7. data/CONFIG.md +16 -0
  8. data/Gemfile +95 -0
  9. data/LICENSE +199 -0
  10. data/README.md +380 -0
  11. data/Rakefile +109 -0
  12. data/examples/DNT.md +35 -0
  13. data/examples/carrying_context.rb +225 -0
  14. data/examples/instrumenting_metal_controller.rb +8 -0
  15. data/examples/puma_on_heroku_config.rb +17 -0
  16. data/examples/tracing_async_threads.rb +125 -0
  17. data/examples/tracing_background_jobs.rb +52 -0
  18. data/examples/tracing_forked_processes.rb +100 -0
  19. data/examples/unicorn_on_heroku_config.rb +28 -0
  20. data/ext/oboe_metal/extconf.rb +61 -0
  21. data/ext/oboe_metal/noop/noop.c +7 -0
  22. data/ext/oboe_metal/src/bson/bson.h +221 -0
  23. data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
  24. data/ext/oboe_metal/src/oboe.h +275 -0
  25. data/ext/oboe_metal/src/oboe.hpp +352 -0
  26. data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
  27. data/ext/oboe_metal/tests/test.rb +11 -0
  28. data/gemfiles/mongo.gemfile +33 -0
  29. data/gemfiles/moped.gemfile +33 -0
  30. data/get_version.rb +5 -0
  31. data/init.rb +4 -0
  32. data/lib/joboe_metal.rb +206 -0
  33. data/lib/oboe.rb +7 -0
  34. data/lib/oboe/README +2 -0
  35. data/lib/oboe/backward_compatibility.rb +59 -0
  36. data/lib/oboe/inst/rack.rb +11 -0
  37. data/lib/oboe_metal.rb +151 -0
  38. data/lib/rails/generators/traceview/install_generator.rb +76 -0
  39. data/lib/rails/generators/traceview/templates/traceview_initializer.rb +159 -0
  40. data/lib/traceview.rb +62 -0
  41. data/lib/traceview/api.rb +18 -0
  42. data/lib/traceview/api/layerinit.rb +51 -0
  43. data/lib/traceview/api/logging.rb +209 -0
  44. data/lib/traceview/api/memcache.rb +31 -0
  45. data/lib/traceview/api/profiling.rb +50 -0
  46. data/lib/traceview/api/tracing.rb +135 -0
  47. data/lib/traceview/api/util.rb +121 -0
  48. data/lib/traceview/base.rb +225 -0
  49. data/lib/traceview/config.rb +238 -0
  50. data/lib/traceview/frameworks/grape.rb +97 -0
  51. data/lib/traceview/frameworks/padrino.rb +64 -0
  52. data/lib/traceview/frameworks/padrino/templates.rb +58 -0
  53. data/lib/traceview/frameworks/rails.rb +145 -0
  54. data/lib/traceview/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
  55. data/lib/traceview/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
  56. data/lib/traceview/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
  57. data/lib/traceview/frameworks/rails/inst/action_controller.rb +216 -0
  58. data/lib/traceview/frameworks/rails/inst/action_view.rb +56 -0
  59. data/lib/traceview/frameworks/rails/inst/action_view_2x.rb +54 -0
  60. data/lib/traceview/frameworks/rails/inst/action_view_30.rb +48 -0
  61. data/lib/traceview/frameworks/rails/inst/active_record.rb +24 -0
  62. data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
  63. data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
  64. data/lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
  65. data/lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
  66. data/lib/traceview/frameworks/rails/inst/connection_adapters/utils.rb +117 -0
  67. data/lib/traceview/frameworks/sinatra.rb +95 -0
  68. data/lib/traceview/frameworks/sinatra/templates.rb +56 -0
  69. data/lib/traceview/inst/cassandra.rb +279 -0
  70. data/lib/traceview/inst/dalli.rb +86 -0
  71. data/lib/traceview/inst/em-http-request.rb +99 -0
  72. data/lib/traceview/inst/excon.rb +111 -0
  73. data/lib/traceview/inst/faraday.rb +73 -0
  74. data/lib/traceview/inst/http.rb +87 -0
  75. data/lib/traceview/inst/httpclient.rb +173 -0
  76. data/lib/traceview/inst/memcache.rb +102 -0
  77. data/lib/traceview/inst/memcached.rb +94 -0
  78. data/lib/traceview/inst/mongo.rb +238 -0
  79. data/lib/traceview/inst/moped.rb +474 -0
  80. data/lib/traceview/inst/rack.rb +122 -0
  81. data/lib/traceview/inst/redis.rb +271 -0
  82. data/lib/traceview/inst/resque.rb +192 -0
  83. data/lib/traceview/inst/rest-client.rb +38 -0
  84. data/lib/traceview/inst/sequel.rb +162 -0
  85. data/lib/traceview/inst/typhoeus.rb +102 -0
  86. data/lib/traceview/instrumentation.rb +21 -0
  87. data/lib/traceview/loading.rb +94 -0
  88. data/lib/traceview/logger.rb +41 -0
  89. data/lib/traceview/method_profiling.rb +84 -0
  90. data/lib/traceview/ruby.rb +36 -0
  91. data/lib/traceview/support.rb +113 -0
  92. data/lib/traceview/thread_local.rb +26 -0
  93. data/lib/traceview/util.rb +250 -0
  94. data/lib/traceview/version.rb +16 -0
  95. data/lib/traceview/xtrace.rb +90 -0
  96. data/test/frameworks/apps/grape_nested.rb +30 -0
  97. data/test/frameworks/apps/grape_simple.rb +24 -0
  98. data/test/frameworks/apps/padrino_simple.rb +45 -0
  99. data/test/frameworks/apps/sinatra_simple.rb +24 -0
  100. data/test/frameworks/grape_test.rb +142 -0
  101. data/test/frameworks/padrino_test.rb +30 -0
  102. data/test/frameworks/sinatra_test.rb +30 -0
  103. data/test/instrumentation/cassandra_test.rb +380 -0
  104. data/test/instrumentation/dalli_test.rb +171 -0
  105. data/test/instrumentation/em_http_request_test.rb +86 -0
  106. data/test/instrumentation/excon_test.rb +207 -0
  107. data/test/instrumentation/faraday_test.rb +235 -0
  108. data/test/instrumentation/http_test.rb +140 -0
  109. data/test/instrumentation/httpclient_test.rb +296 -0
  110. data/test/instrumentation/memcache_test.rb +251 -0
  111. data/test/instrumentation/memcached_test.rb +226 -0
  112. data/test/instrumentation/mongo_test.rb +462 -0
  113. data/test/instrumentation/moped_test.rb +496 -0
  114. data/test/instrumentation/rack_test.rb +116 -0
  115. data/test/instrumentation/redis_hashes_test.rb +265 -0
  116. data/test/instrumentation/redis_keys_test.rb +318 -0
  117. data/test/instrumentation/redis_lists_test.rb +310 -0
  118. data/test/instrumentation/redis_misc_test.rb +160 -0
  119. data/test/instrumentation/redis_sets_test.rb +293 -0
  120. data/test/instrumentation/redis_sortedsets_test.rb +325 -0
  121. data/test/instrumentation/redis_strings_test.rb +333 -0
  122. data/test/instrumentation/resque_test.rb +62 -0
  123. data/test/instrumentation/rest-client_test.rb +294 -0
  124. data/test/instrumentation/sequel_mysql2_test.rb +326 -0
  125. data/test/instrumentation/sequel_mysql_test.rb +326 -0
  126. data/test/instrumentation/sequel_pg_test.rb +330 -0
  127. data/test/instrumentation/typhoeus_test.rb +285 -0
  128. data/test/minitest_helper.rb +187 -0
  129. data/test/profiling/method_test.rb +198 -0
  130. data/test/servers/rackapp_8101.rb +22 -0
  131. data/test/support/backcompat_test.rb +269 -0
  132. data/test/support/config_test.rb +128 -0
  133. data/test/support/dnt_test.rb +73 -0
  134. data/test/support/liboboe_settings_test.rb +104 -0
  135. data/test/support/xtrace_test.rb +35 -0
  136. data/traceview.gemspec +29 -0
  137. metadata +250 -0
@@ -0,0 +1,145 @@
1
+ # Copyright (c) 2013 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ module TraceView
5
+ module Rails
6
+ module Helpers
7
+ extend ActiveSupport::Concern if defined?(::Rails) and ::Rails::VERSION::MAJOR > 2
8
+
9
+ @@rum_xhr_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_ajax_header.js.erb')
10
+ @@rum_hdr_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_header.js.erb')
11
+ @@rum_ftr_tmpl = File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_footer.js.erb')
12
+
13
+ def traceview_rum_header
14
+ begin
15
+ return unless TraceView::Config.rum_id
16
+ if TraceView.tracing?
17
+ if request.xhr?
18
+ return raw(ERB.new(@@rum_xhr_tmpl).result)
19
+ else
20
+ return raw(ERB.new(@@rum_hdr_tmpl).result)
21
+ end
22
+ end
23
+ rescue StandardError => e
24
+ TraceView.logger.warn "traceview_rum_header: #{e.message}."
25
+ return ""
26
+ end
27
+ end
28
+
29
+ def traceview_rum_footer
30
+ begin
31
+ return unless TraceView::Config.rum_id
32
+ if TraceView.tracing?
33
+ # Even though the footer template is named xxxx.erb, there are no ERB tags in it so we'll
34
+ # skip that step for now
35
+ return raw(@@rum_ftr_tmpl)
36
+ end
37
+ rescue StandardError => e
38
+ TraceView.logger.warn "traceview_rum_footer: #{e.message}."
39
+ return ""
40
+ end
41
+ end
42
+ end # Helpers
43
+
44
+ def self.load_initializer
45
+ # Force load the TraceView Rails initializer if there is one
46
+ # Prefer traceview.rb but give priority to the legacy tracelytics.rb if it exists
47
+ if ::Rails::VERSION::MAJOR > 2
48
+ rails_root = "#{::Rails.root.to_s}"
49
+ else
50
+ rails_root = "#{RAILS_ROOT}"
51
+ end
52
+
53
+ #
54
+ # We've been through 3 initializer names. Try each one.
55
+ #
56
+ if File.exists?("#{rails_root}/config/initializers/tracelytics.rb")
57
+ tr_initializer = "#{rails_root}/config/initializers/tracelytics.rb"
58
+
59
+ elsif File.exists?("#{rails_root}/config/initializers/oboe.rb")
60
+ tr_initializer = "#{rails_root}/config/initializers/oboe.rb"
61
+
62
+ else
63
+ tr_initializer = "#{rails_root}/config/initializers/traceview.rb"
64
+ end
65
+ require tr_initializer if File.exists?(tr_initializer)
66
+ end
67
+
68
+ def self.load_instrumentation
69
+ # Load the Rails specific instrumentation
70
+ pattern = File.join(File.dirname(__FILE__), 'rails/inst', '*.rb')
71
+ Dir.glob(pattern) do |f|
72
+ begin
73
+ require f
74
+ rescue => e
75
+ TraceView.logger.error "[traceview/loading] Error loading rails insrumentation file '#{f}' : #{e}"
76
+ end
77
+ end
78
+
79
+ TraceView.logger.info "TraceView gem #{TraceView::Version::STRING} successfully loaded."
80
+ end
81
+
82
+ def self.include_helpers
83
+ # TBD: This would make the helpers available to controllers which is occasionally desired.
84
+ # ActiveSupport.on_load(:action_controller) do
85
+ # include TraceView::Rails::Helpers
86
+ # end
87
+ if ::Rails::VERSION::MAJOR > 2
88
+ ActiveSupport.on_load(:action_view) do
89
+ include TraceView::Rails::Helpers
90
+ end
91
+ else
92
+ ActionView::Base.send :include, TraceView::Rails::Helpers
93
+ end
94
+ end
95
+
96
+ end # Rails
97
+ end # TraceView
98
+
99
+ if defined?(::Rails)
100
+ require 'traceview/inst/rack'
101
+
102
+ if ::Rails::VERSION::MAJOR > 2
103
+ module TraceView
104
+ class Railtie < ::Rails::Railtie
105
+
106
+ initializer 'traceview.helpers' do
107
+ TraceView::Rails.include_helpers
108
+ end
109
+
110
+ initializer 'traceview.rack' do |app|
111
+ TraceView.logger.info "[traceview/loading] Instrumenting rack" if TraceView::Config[:verbose]
112
+ app.config.middleware.insert 0, "TraceView::Rack"
113
+ end
114
+
115
+ config.after_initialize do
116
+ TraceView.logger = ::Rails.logger if ::Rails.logger
117
+
118
+ TraceView::Loading.load_access_key
119
+ TraceView::Inst.load_instrumentation
120
+ TraceView::Rails.load_instrumentation
121
+
122
+ # Report __Init after fork when in Heroku
123
+ TraceView::API.report_init unless TraceView.heroku?
124
+ end
125
+ end
126
+ end
127
+ else
128
+ TraceView.logger = ::Rails.logger if ::Rails.logger
129
+
130
+ TraceView::Rails.load_initializer
131
+ TraceView::Loading.load_access_key
132
+
133
+ Rails.configuration.after_initialize do
134
+ TraceView.logger.info "[traceview/loading] Instrumenting rack" if TraceView::Config[:verbose]
135
+ Rails.configuration.middleware.insert 0, "TraceView::Rack"
136
+
137
+ TraceView::Inst.load_instrumentation
138
+ TraceView::Rails.load_instrumentation
139
+ TraceView::Rails.include_helpers
140
+
141
+ # Report __Init after fork when in Heroku
142
+ TraceView::API.report_init unless TraceView.heroku?
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,5 @@
1
+ <script type="text/javascript">(function(){var d=this._tly={q:[],mark:function(a,b){d.q.push(["mark",a,b||(new Date).getTime()])},measure:function(a,b,c){d.q.push(["measure",a,b,c||(new Date).getTime()])},done:function(a){d.q.push(["done",a])},cid:"<%= TraceView::Config[:rum_id] %>",xt:"<%= TraceView::Context.toString %>"};d.mark("firstbyte");var f;f=function(){};var g=0;function h(a){return function(b){b[a]||(b[a]=!0,d.measure(["_ajax",b.a,a]))}}var i=h("recv"),j=h("send");
2
+ function l(){var a=this&&this._tl,b=a.b;4===this.readyState&&i(a);f();for(a=0;a<b.length;a++)b[a].apply(this,arguments)}var m=this.XMLHttpRequest,n=m&&m.prototype;
3
+ if(n){var o=n.open;n.open=function(a,b,c,e,u){f();this._tl||(this._tl={a:g++,async:c,b:[]},d.measure(["_ajax",this._tl.a,"init",a,b]));return e?o.call(this,a,b,c,e,u):o.call(this,a,b,c)};var p=n.send;n.send=function(a){function b(){try{var a;a:{var b=l;try{if(c.addEventListener){c.addEventListener("readystatechange",b);a=!0;break a}}catch(w){}a=!1}if(!a){var k=c.onreadystatechange;if(k){if(!k.apply)return;f();e.b.push(k)}f();c.onreadystatechange=l}}catch(x){}}var c=this,e=c&&c._tl;f();b();j(e);a=
4
+ p.call(c,a);!e.async||4===c.readyState?i(e):setTimeout(function(){try{4===c.readyState?i(e):c.onreadystatechange!==l&&b()}catch(a){}},0);return a}}this.onerror=function(a,b,c){d.measure(["_jserror ",a,"|",b,"|",c].join(""))};var q=this.attachEvent,r=this.addEventListener;var s=function(){d.measure("winload");d.done()};q?q("onload",s):r&&r("load",s,!1);var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src=("http:"===document.location.protocol?"http:":"https:")+"//d2gfdmu30u15x7.cloudfront.net/1/tly.js";
5
+ var v=document.getElementsByTagName("script")[0];v.parentNode.insertBefore(t,v);}());</script>
@@ -0,0 +1 @@
1
+ <script type="text/javascript">this._tly&&this._tly.measure("domload");</script>
@@ -0,0 +1,3 @@
1
+ <script type="text/javascript">(function(){var b=this._tly={q:[],mark:function(a,c){b.q.push(["mark",a,c||(new Date).getTime()])},measure:function(a,c,e){b.q.push(["measure",a,c,e||(new Date).getTime()])},done:function(a){b.q.push(["done",a])},cid:"<%= TraceView::Config[:rum_id] %>",xt:"<%= TraceView::Context.toString %>"};b.mark("firstbyte");this.onerror=function(a,c,e){b.measure(["_jserror ",a,"|",c,"|",e].join(""))};var d=this.attachEvent,f=this.addEventListener;var g=function(){b.measure("winload");b.done()};d?d("onload",g):f&&f("load",g,!1);var h=document.createElement("script");
2
+ h.type="text/javascript";h.async=!0;h.src=("http:"===document.location.protocol?"http:":"https:")+"//d2gfdmu30u15x7.cloudfront.net/1/tly.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(h,i);}());</script>
3
+
@@ -0,0 +1,216 @@
1
+ # Copyright (c) 2013 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ module TraceView
5
+ module Inst
6
+ #
7
+ # RailsBase
8
+ #
9
+ # This module contains the instrumentation code common to
10
+ # many Rails versions.
11
+ #
12
+ module RailsBase
13
+ #
14
+ # has_handler?
15
+ #
16
+ # Determins if <tt>exception</tt> has a registered
17
+ # handler via <tt>rescue_from</tt>
18
+ #
19
+ def has_handler?(exception)
20
+ # Don't log exceptions if they have a rescue handler set
21
+ has_handler = false
22
+ rescue_handlers.detect { | klass_name, handler |
23
+ # Rescue handlers can be specified as strings or constant names
24
+ klass = self.class.const_get(klass_name) rescue nil
25
+ klass ||= klass_name.constantize rescue nil
26
+ has_handler = exception.is_a?(klass) if klass
27
+ }
28
+ has_handler
29
+ rescue => e
30
+ TraceView.logger.debug "[traceview/debug] Error searching Rails handlers: #{e.message}"
31
+ return false
32
+ end
33
+
34
+ #
35
+ # log_rails_error?
36
+ #
37
+ # Determins whether we should log a raised exception to the
38
+ # TraceView dashboard. This is determined by whether the exception
39
+ # has a rescue handler setup and the value of
40
+ # TraceView::Config[:report_rescued_errors]
41
+ #
42
+ def log_rails_error?(exception)
43
+ # As it's perculating up through the layers... make sure that
44
+ # we only report it once.
45
+ return false if exception.instance_variable_get(:@traceview_logged)
46
+
47
+ has_handler = has_handler?(exception)
48
+
49
+ if !has_handler || (has_handler && TraceView::Config[:report_rescued_errors])
50
+ return true
51
+ end
52
+ false
53
+ end
54
+
55
+ #
56
+ # render_with_traceview
57
+ #
58
+ # Our render wrapper that just times and conditionally
59
+ # reports raised exceptions
60
+ #
61
+ def render_with_traceview(*args, &blk)
62
+ TraceView::API.log_entry('actionview')
63
+ render_without_traceview(*args, &blk)
64
+
65
+ rescue Exception => e
66
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
67
+ raise
68
+ ensure
69
+ TraceView::API.log_exit('actionview')
70
+ end
71
+ end
72
+
73
+ #
74
+ # ActionController3
75
+ #
76
+ # This modules contains the instrumentation code specific
77
+ # to Rails v3
78
+ #
79
+ module ActionController3
80
+ include ::TraceView::Inst::RailsBase
81
+
82
+ def self.included(base)
83
+ base.class_eval do
84
+ alias_method_chain :process, :traceview
85
+ alias_method_chain :process_action, :traceview
86
+ alias_method_chain :render, :traceview
87
+ end
88
+ end
89
+
90
+ def process_with_traceview(*args)
91
+ TraceView::API.log_entry('rails')
92
+ process_without_traceview *args
93
+
94
+ rescue Exception => e
95
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
96
+ raise
97
+ ensure
98
+ TraceView::API.log_exit('rails')
99
+ end
100
+
101
+ def process_action_with_traceview(*args)
102
+ report_kvs = {
103
+ :Controller => self.class.name,
104
+ :Action => self.action_name,
105
+ }
106
+ TraceView::API.log(nil, 'info', report_kvs)
107
+
108
+ process_action_without_traceview *args
109
+ rescue Exception
110
+ report_kvs[:Status] = 500
111
+ TraceView::API.log(nil, 'info', report_kvs)
112
+ raise
113
+ end
114
+ end
115
+
116
+ #
117
+ # ActionController4
118
+ #
119
+ # This modules contains the instrumentation code specific
120
+ # to Rails v4
121
+ #
122
+ module ActionController4
123
+ include ::TraceView::Inst::RailsBase
124
+
125
+ def self.included(base)
126
+ base.class_eval do
127
+ alias_method_chain :process_action, :traceview
128
+ alias_method_chain :render, :traceview
129
+ end
130
+ end
131
+
132
+ def process_action_with_traceview(method_name, *args)
133
+ return process_action_without_traceview(method_name, *args) if TraceView::Config[:action_blacklist].present? &&
134
+ TraceView::Config[:action_blacklist][[self.controller_name, self.action_name].join('#')]
135
+
136
+ report_kvs = {
137
+ :Controller => self.class.name,
138
+ :Action => self.action_name,
139
+ }
140
+
141
+ TraceView::API.log_entry('rails')
142
+ process_action_without_traceview(method_name, *args)
143
+
144
+ rescue Exception => e
145
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
146
+ raise
147
+ ensure
148
+ TraceView::API.log_exit('rails')
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ if defined?(ActionController::Base) && TraceView::Config[:action_controller][:enabled]
155
+ if ::Rails::VERSION::MAJOR == 4
156
+
157
+ class ActionController::Base
158
+ include TraceView::Inst::ActionController4
159
+ end
160
+
161
+ elsif ::Rails::VERSION::MAJOR == 3
162
+
163
+ class ActionController::Base
164
+ include TraceView::Inst::ActionController3
165
+ end
166
+
167
+ elsif ::Rails::VERSION::MAJOR == 2
168
+
169
+ ActionController::Base.class_eval do
170
+ include ::TraceView::Inst::RailsBase
171
+
172
+ alias :perform_action_without_traceview :perform_action
173
+ alias :rescue_action_without_traceview :rescue_action
174
+ alias :process_without_traceview :process
175
+ alias :render_without_traceview :render
176
+
177
+ def process(*args)
178
+ TraceView::API.log_entry('rails')
179
+ process_without_traceview(*args)
180
+
181
+ rescue Exception => e
182
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
183
+ raise
184
+ ensure
185
+ TraceView::API.log_exit('rails')
186
+ end
187
+
188
+ def perform_action(*arguments)
189
+ report_kvs = {
190
+ :Controller => @_request.path_parameters['controller'],
191
+ :Action => @_request.path_parameters['action']
192
+ }
193
+ TraceView::API.log(nil, 'info', report_kvs)
194
+ perform_action_without_traceview(*arguments)
195
+ end
196
+
197
+ def rescue_action(exn)
198
+ TraceView::API.log_exception(nil, exn) if log_rails_error?(exn)
199
+ rescue_action_without_traceview(exn)
200
+ end
201
+
202
+ def render(options = nil, extra_options = {}, &block)
203
+ TraceView::API.log_entry('actionview')
204
+ render_without_traceview(options, extra_options, &block)
205
+
206
+ rescue Exception => e
207
+ TraceView::API.log_exception(nil, e) if log_rails_error?(e)
208
+ raise
209
+ ensure
210
+ TraceView::API.log_exit('actionview')
211
+ end
212
+ end
213
+ end
214
+ TraceView.logger.info '[traceview/loading] Instrumenting actioncontroler' if TraceView::Config[:verbose]
215
+ end
216
+ # vim:set expandtab:tabstop=2
@@ -0,0 +1,56 @@
1
+ # Copyright (c) 2013 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ if defined?(ActionView::Base) && TraceView::Config[:action_view][:enabled]
5
+
6
+ ##
7
+ # ActionView Instrumentation is version dependent. ActionView 2.x is separate
8
+ # and ActionView 3.0 is a special case.
9
+ # Everything else goes here. (ActionView 3.1 - 4.0 as of this writing)
10
+ #
11
+ if (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0) || Rails::VERSION::MAJOR == 4
12
+
13
+ TraceView.logger.info '[traceview/loading] Instrumenting actionview' if TraceView::Config[:verbose]
14
+
15
+ ActionView::PartialRenderer.class_eval do
16
+ alias :render_partial_without_traceview :render_partial
17
+ def render_partial
18
+ entry_kvs = {}
19
+ begin
20
+ name = TraceView::Util.prettify(@options[:partial]) if @options.is_a?(Hash)
21
+ entry_kvs[:FunctionName] = :render_partial
22
+ entry_kvs[:Class] = :PartialRenderer
23
+ entry_kvs[:Module] = :ActionView
24
+ entry_kvs[:File] = __FILE__
25
+ entry_kvs[:LineNumber] = __LINE__
26
+ rescue
27
+ end
28
+
29
+ TraceView::API.profile(name, entry_kvs, TraceView::Config[:action_view][:collect_backtraces]) do
30
+ render_partial_without_traceview
31
+ end
32
+ end
33
+
34
+ alias :render_collection_without_traceview :render_collection
35
+ def render_collection
36
+ entry_kvs = {}
37
+ begin
38
+ name = TraceView::Util.prettify(@path)
39
+ entry_kvs[:FunctionName] = :render_collection
40
+ entry_kvs[:Class] = :PartialRenderer
41
+ entry_kvs[:Module] = :ActionView
42
+ entry_kvs[:File] = __FILE__
43
+ entry_kvs[:LineNumber] = __LINE__
44
+ rescue
45
+ end
46
+
47
+ TraceView::API.profile(name, entry_kvs, TraceView::Config[:action_view][:collect_backtraces]) do
48
+ render_collection_without_traceview
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+
56
+ # vim:set expandtab:tabstop=2
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2013 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ if defined?(ActionView::Base) && TraceView::Config[:action_view][:enabled]
5
+
6
+ if Rails::VERSION::MAJOR == 2
7
+
8
+ TraceView.logger.info '[traceview/loading] Instrumenting actionview' if TraceView::Config[:verbose]
9
+
10
+ ActionView::Partials.module_eval do
11
+ alias :render_partial_without_traceview :render_partial
12
+ def render_partial(options = {})
13
+ if options.key?(:partial) && options[:partial].is_a?(String)
14
+ entry_kvs = {}
15
+ begin
16
+ name = TraceView::Util.prettify(options[:partial]) if options.is_a?(Hash)
17
+ entry_kvs[:FunctionName] = :render_partial
18
+ entry_kvs[:Class] = :Partials
19
+ entry_kvs[:Module] = :ActionView
20
+ entry_kvs[:File] = __FILE__
21
+ entry_kvs[:LineNumber] = __LINE__
22
+ rescue
23
+ end
24
+
25
+ TraceView::API.profile(name, entry_kvs, TraceView::Config[:action_view][:collect_backtraces]) do
26
+ render_partial_without_traceview(options)
27
+ end
28
+ else
29
+ render_partial_without_traceview(options)
30
+ end
31
+ end
32
+
33
+ alias :render_partial_collection_without_traceview :render_partial_collection
34
+ def render_partial_collection(options = {})
35
+ entry_kvs = {}
36
+ begin
37
+ name = 'partial_collection'
38
+ entry_kvs[:FunctionName] = :render_partial_collection
39
+ entry_kvs[:Class] = :Partials
40
+ entry_kvs[:Module] = :ActionView
41
+ entry_kvs[:File] = __FILE__
42
+ entry_kvs[:LineNumber] = __LINE__
43
+ rescue
44
+ end
45
+
46
+ TraceView::API.profile(name, entry_kvs, TraceView::Config[:action_view][:collect_backtraces]) do
47
+ render_partial_collection_without_traceview(options)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ # vim:set expandtab:tabstop=2