oboe 2.7.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +51 -0
- data/Appraisals +10 -0
- data/CHANGELOG.md +223 -0
- data/Gemfile +49 -0
- data/LICENSE +199 -0
- data/README.md +380 -0
- data/Rakefile +106 -0
- data/ext/oboe_metal/extconf.rb +61 -0
- data/ext/oboe_metal/noop/noop.c +7 -0
- data/ext/oboe_metal/src/bson/bson.h +221 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/oboe.h +275 -0
- data/ext/oboe_metal/src/oboe.hpp +352 -0
- data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
- data/ext/oboe_metal/tests/test.rb +11 -0
- data/gemfiles/mongo.gemfile +33 -0
- data/gemfiles/moped.gemfile +33 -0
- data/get_version.rb +5 -0
- data/init.rb +4 -0
- data/lib/base.rb +99 -0
- data/lib/joboe_metal.rb +185 -0
- data/lib/method_profiling.rb +70 -0
- data/lib/oboe.rb +50 -0
- data/lib/oboe/api.rb +14 -0
- data/lib/oboe/api/layerinit.rb +99 -0
- data/lib/oboe/api/logging.rb +129 -0
- data/lib/oboe/api/memcache.rb +29 -0
- data/lib/oboe/api/profiling.rb +50 -0
- data/lib/oboe/api/tracing.rb +134 -0
- data/lib/oboe/api/util.rb +117 -0
- data/lib/oboe/config.rb +140 -0
- data/lib/oboe/frameworks/grape.rb +74 -0
- data/lib/oboe/frameworks/padrino.rb +66 -0
- data/lib/oboe/frameworks/padrino/templates.rb +59 -0
- data/lib/oboe/frameworks/rails.rb +139 -0
- data/lib/oboe/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
- data/lib/oboe/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
- data/lib/oboe/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +123 -0
- data/lib/oboe/frameworks/rails/inst/action_view.rb +56 -0
- data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +54 -0
- data/lib/oboe/frameworks/rails/inst/action_view_30.rb +48 -0
- data/lib/oboe/frameworks/rails/inst/active_record.rb +24 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +118 -0
- data/lib/oboe/frameworks/sinatra.rb +96 -0
- data/lib/oboe/frameworks/sinatra/templates.rb +56 -0
- data/lib/oboe/inst/cassandra.rb +281 -0
- data/lib/oboe/inst/dalli.rb +75 -0
- data/lib/oboe/inst/http.rb +72 -0
- data/lib/oboe/inst/memcache.rb +105 -0
- data/lib/oboe/inst/memcached.rb +96 -0
- data/lib/oboe/inst/mongo.rb +240 -0
- data/lib/oboe/inst/moped.rb +474 -0
- data/lib/oboe/inst/rack.rb +81 -0
- data/lib/oboe/inst/redis.rb +273 -0
- data/lib/oboe/inst/resque.rb +193 -0
- data/lib/oboe/instrumentation.rb +18 -0
- data/lib/oboe/loading.rb +98 -0
- data/lib/oboe/logger.rb +41 -0
- data/lib/oboe/ruby.rb +11 -0
- data/lib/oboe/util.rb +129 -0
- data/lib/oboe/version.rb +13 -0
- data/lib/oboe/xtrace.rb +52 -0
- data/lib/oboe_metal.rb +140 -0
- data/lib/rails/generators/oboe/install_generator.rb +76 -0
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +94 -0
- data/oboe.gemspec +29 -0
- data/release.sh +65 -0
- data/test/frameworks/apps/grape_simple.rb +10 -0
- data/test/frameworks/apps/padrino_simple.rb +41 -0
- data/test/frameworks/apps/sinatra_simple.rb +20 -0
- data/test/frameworks/grape_test.rb +27 -0
- data/test/frameworks/padrino_test.rb +25 -0
- data/test/frameworks/sinatra_test.rb +25 -0
- data/test/instrumentation/cassandra_test.rb +381 -0
- data/test/instrumentation/dalli_test.rb +164 -0
- data/test/instrumentation/http_test.rb +97 -0
- data/test/instrumentation/memcache_test.rb +251 -0
- data/test/instrumentation/memcached_test.rb +226 -0
- data/test/instrumentation/mongo_test.rb +462 -0
- data/test/instrumentation/moped_test.rb +473 -0
- data/test/instrumentation/rack_test.rb +73 -0
- data/test/instrumentation/redis_hashes_test.rb +265 -0
- data/test/instrumentation/redis_keys_test.rb +318 -0
- data/test/instrumentation/redis_lists_test.rb +310 -0
- data/test/instrumentation/redis_misc_test.rb +160 -0
- data/test/instrumentation/redis_sets_test.rb +293 -0
- data/test/instrumentation/redis_sortedsets_test.rb +325 -0
- data/test/instrumentation/redis_strings_test.rb +333 -0
- data/test/instrumentation/resque_test.rb +62 -0
- data/test/minitest_helper.rb +148 -0
- data/test/profiling/method_test.rb +198 -0
- data/test/support/config_test.rb +39 -0
- data/test/support/liboboe_settings_test.rb +46 -0
- data/test/support/xtrace_test.rb +35 -0
- metadata +200 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
module Oboe
|
7
|
+
module API
|
8
|
+
module Util
|
9
|
+
BACKTRACE_CUTOFF = 200
|
10
|
+
|
11
|
+
# Internal: Check whether the provided key is reserved or not. Reserved
|
12
|
+
# keys are either keys that are handled by liboboe calls or the oboe gem.
|
13
|
+
#
|
14
|
+
# key - the key to check.
|
15
|
+
#
|
16
|
+
# Return a boolean indicating whether or not key is reserved.
|
17
|
+
def valid_key?(key)
|
18
|
+
!%w[ Label Layer Edge Timestamp Timestamp_u ].include? key.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
# Internal: Get the current backtrace.
|
22
|
+
#
|
23
|
+
# ignore - Number of frames to ignore at the end of the backtrace. Use
|
24
|
+
# when you know how many layers deep in oboe the call is being
|
25
|
+
# made.
|
26
|
+
#
|
27
|
+
# Returns a string with each frame of the backtrace separated by '\r\n'.
|
28
|
+
def backtrace(ignore=1)
|
29
|
+
trim_backtrace(Kernel.caller).join("\r\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Internal: Trim a backtrace to a manageable size
|
33
|
+
#
|
34
|
+
# backtrace - the backtrace (an array of stack frames/from Kernel.caller)
|
35
|
+
#
|
36
|
+
# Returns a trimmed backtrace
|
37
|
+
def trim_backtrace(backtrace)
|
38
|
+
return backtrace unless backtrace.is_a?(Array)
|
39
|
+
|
40
|
+
length = backtrace.size
|
41
|
+
if length > BACKTRACE_CUTOFF
|
42
|
+
# Trim backtraces by getting the first 180 and last 20 lines
|
43
|
+
trimmed = backtrace[0, 180] + ['...[snip]...'] + backtrace[length - 20, 20]
|
44
|
+
else
|
45
|
+
trimmed = backtrace
|
46
|
+
end
|
47
|
+
trimmed
|
48
|
+
end
|
49
|
+
|
50
|
+
# Internal: Check if a host is blacklisted from tracing
|
51
|
+
#
|
52
|
+
# addr_port - the addr_port from Net::HTTP although this method
|
53
|
+
# can be used from any component in reality
|
54
|
+
#
|
55
|
+
# Returns a boolean on blacklisted state
|
56
|
+
def blacklisted?(addr_port)
|
57
|
+
return false unless Oboe::Config.blacklist
|
58
|
+
|
59
|
+
# Ensure that the blacklist is an array
|
60
|
+
unless Oboe::Config.blacklist.is_a?(Array)
|
61
|
+
val = Oboe::Config[:blacklist]
|
62
|
+
Oboe::Config[:blacklist] = [ val.to_s ]
|
63
|
+
end
|
64
|
+
|
65
|
+
Oboe::Config.blacklist.each do |h|
|
66
|
+
return true if addr_port.to_s.match(h.to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
false
|
70
|
+
end
|
71
|
+
|
72
|
+
# Internal: Pretty print a list of arguments for reporting
|
73
|
+
#
|
74
|
+
# args - the list of arguments to work on
|
75
|
+
#
|
76
|
+
# Returns a pretty string representation of arguments
|
77
|
+
def pps(*args)
|
78
|
+
old_out = $stdout
|
79
|
+
begin
|
80
|
+
s = StringIO.new
|
81
|
+
$stdout = s
|
82
|
+
pp(*args)
|
83
|
+
ensure
|
84
|
+
$stdout = old_out
|
85
|
+
end
|
86
|
+
s.string
|
87
|
+
end
|
88
|
+
|
89
|
+
# Internal: Determine a string to report representing klass
|
90
|
+
#
|
91
|
+
# args - an instance of a Class, a Class or a Module
|
92
|
+
#
|
93
|
+
# Returns a string representation of klass
|
94
|
+
def get_class_name(klass)
|
95
|
+
kv = {}
|
96
|
+
if klass.to_s =~ /::/
|
97
|
+
klass.class.to_s.rpartition('::').last
|
98
|
+
else
|
99
|
+
if klass.is_a?(Class) and klass.is_a?(Module)
|
100
|
+
# Class
|
101
|
+
kv["Class"] = klass.to_s
|
102
|
+
|
103
|
+
elsif (not klass.is_a?(Class) and not klass.is_a?(Module))
|
104
|
+
# Class instance
|
105
|
+
kv["Class"] = klass.class.to_s
|
106
|
+
|
107
|
+
else
|
108
|
+
# Module
|
109
|
+
kv["Module"] = klass.to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
kv
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/lib/oboe/config.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
##
|
6
|
+
# This module exposes a nested configuration hash that can be used to
|
7
|
+
# configure and/or modify the functionality of the oboe gem.
|
8
|
+
#
|
9
|
+
# Use Oboe::Config.show to view the entire nested hash.
|
10
|
+
#
|
11
|
+
module Config
|
12
|
+
@@config = {}
|
13
|
+
|
14
|
+
@@instrumentation = [ :cassandra, :dalli, :nethttp, :memcached, :memcache, :mongo,
|
15
|
+
:moped, :rack, :redis, :resque, :action_controller, :action_view,
|
16
|
+
:active_record ]
|
17
|
+
|
18
|
+
##
|
19
|
+
# Return the raw nested hash.
|
20
|
+
#
|
21
|
+
def self.show
|
22
|
+
@@config
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.initialize(data={})
|
26
|
+
# Setup default instrumentation values
|
27
|
+
@@instrumentation.each do |k|
|
28
|
+
@@config[k] = {}
|
29
|
+
@@config[k][:enabled] = true
|
30
|
+
@@config[k][:collect_backtraces] = false
|
31
|
+
@@config[k][:log_args] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# Set collect_backtraces defaults
|
35
|
+
Oboe::Config[:action_controller][:collect_backtraces] = true
|
36
|
+
Oboe::Config[:active_record][:collect_backtraces] = true
|
37
|
+
Oboe::Config[:action_view][:collect_backtraces] = true
|
38
|
+
Oboe::Config[:cassandra][:collect_backtraces] = true
|
39
|
+
Oboe::Config[:dalli][:collect_backtraces] = false
|
40
|
+
Oboe::Config[:memcache][:collect_backtraces] = false
|
41
|
+
Oboe::Config[:memcached][:collect_backtraces] = false
|
42
|
+
Oboe::Config[:mongo][:collect_backtraces] = true
|
43
|
+
Oboe::Config[:moped][:collect_backtraces] = true
|
44
|
+
Oboe::Config[:nethttp][:collect_backtraces] = true
|
45
|
+
Oboe::Config[:redis][:collect_backtraces] = false
|
46
|
+
Oboe::Config[:resque][:collect_backtraces] = true
|
47
|
+
|
48
|
+
# Special instrument specific flags
|
49
|
+
#
|
50
|
+
# :link_workers - associates enqueue operations with the jobs they queue by piggybacking
|
51
|
+
# an additional argument that is stripped prior to job proecessing
|
52
|
+
# !!Note: Make sure both the queue side and the Resque workers are instrumented
|
53
|
+
# or jobs will fail
|
54
|
+
# (Default: false)
|
55
|
+
@@config[:resque][:link_workers] = false
|
56
|
+
|
57
|
+
# Setup an empty host blacklist (see: Oboe::API::Util.blacklisted?)
|
58
|
+
@@config[:blacklist] = []
|
59
|
+
|
60
|
+
# Access Key is empty until loaded from config file or env var
|
61
|
+
@@config[:access_key] = ""
|
62
|
+
|
63
|
+
# The oboe Ruby client has the ability to sanitize query literals
|
64
|
+
# from SQL statements. By default this is disabled. Enable to
|
65
|
+
# avoid collecting and reporting query literals to TraceView.
|
66
|
+
@@config[:sanitize_sql] = false
|
67
|
+
|
68
|
+
if ENV.has_key?('OPENSHIFT_TRACEVIEW_TLYZER_IP')
|
69
|
+
# We're running on OpenShift
|
70
|
+
@@config[:tracing_mode] = "always"
|
71
|
+
@@config[:reporter_host] = ENV['OPENSHIFT_TRACEVIEW_TLYZER_IP']
|
72
|
+
@@config[:reporter_port] = ENV['OPENSHIFT_TRACEVIEW_TLYZER_PORT']
|
73
|
+
else
|
74
|
+
# The default configuration
|
75
|
+
@@config[:tracing_mode] = "through"
|
76
|
+
@@config[:reporter_host] = "127.0.0.1"
|
77
|
+
@@config[:reporter_port] = "7831"
|
78
|
+
end
|
79
|
+
|
80
|
+
@@config[:verbose] = false
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.update!(data)
|
84
|
+
data.each do |key, value|
|
85
|
+
self[key] = value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.merge!(data)
|
90
|
+
self.update!(data)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.[](key)
|
94
|
+
@@config[key.to_sym]
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.[]=(key, value)
|
98
|
+
@@config[key.to_sym] = value
|
99
|
+
|
100
|
+
if key == :sampling_rate
|
101
|
+
Oboe.logger.warn "WARNING: :sampling_rate is not a supported setting for Oboe::Config. Please use :sample_rate."
|
102
|
+
end
|
103
|
+
|
104
|
+
if key == :sample_rate
|
105
|
+
unless value.is_a?(Integer) or value.is_a?(Float)
|
106
|
+
raise "oboe :sample_rate must be a number between 1 and 1000000 (1m)"
|
107
|
+
end
|
108
|
+
|
109
|
+
# Validate :sample_rate value
|
110
|
+
unless value.between?(1, 1e6)
|
111
|
+
raise "oboe :sample_rate must be between 1 and 1000000 (1m)"
|
112
|
+
end
|
113
|
+
|
114
|
+
# Assure value is an integer
|
115
|
+
@@config[key.to_sym] = value.to_i
|
116
|
+
|
117
|
+
Oboe.set_sample_rate(value)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Update liboboe if updating :tracing_mode
|
121
|
+
if key == :tracing_mode
|
122
|
+
Oboe.set_tracing_mode(value)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.method_missing(sym, *args)
|
127
|
+
if sym.to_s =~ /(.+)=$/
|
128
|
+
self[$1] = args.first
|
129
|
+
else
|
130
|
+
unless @@config.has_key?(sym)
|
131
|
+
Oboe.logger.warn "[oboe/warn] Unknown method call on Oboe::Config: #{sym}"
|
132
|
+
end
|
133
|
+
self[sym]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
Oboe::Config.initialize
|
140
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module Grape
|
6
|
+
module API
|
7
|
+
def self.extended(klass)
|
8
|
+
::Oboe::Util.class_method_alias(klass, :inherited, ::Grape::API)
|
9
|
+
end
|
10
|
+
|
11
|
+
def inherited_with_oboe(subclass)
|
12
|
+
inherited_without_oboe(subclass)
|
13
|
+
|
14
|
+
subclass.use ::Oboe::Rack
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Endpoint
|
19
|
+
def self.included(klass)
|
20
|
+
::Oboe::Util.method_alias(klass, :run, ::Grape::Endpoint)
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_with_oboe(env)
|
24
|
+
if Oboe.tracing?
|
25
|
+
report_kvs = {}
|
26
|
+
|
27
|
+
report_kvs[:Controller] = self.class
|
28
|
+
report_kvs[:Action] = env['PATH_INFO']
|
29
|
+
|
30
|
+
# Fall back to the raw tracing API so we can pass KVs
|
31
|
+
# back on exit (a limitation of the Oboe::API.trace
|
32
|
+
# block method) This removes the need for an info
|
33
|
+
# event to send additonal KVs
|
34
|
+
::Oboe::API.log_entry('grape', {})
|
35
|
+
|
36
|
+
begin
|
37
|
+
run_without_oboe(env)
|
38
|
+
ensure
|
39
|
+
::Oboe::API.log_exit('grape', report_kvs)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
run_without_oboe(env)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module Middleware
|
48
|
+
module Error
|
49
|
+
def self.included(klass)
|
50
|
+
::Oboe::Util.method_alias(klass, :call, ::Grape::Middleware::Error)
|
51
|
+
end
|
52
|
+
|
53
|
+
def call_with_oboe(boom)
|
54
|
+
Oboe::API.log_exception(nil, boom) if Oboe.tracing?
|
55
|
+
call_without_oboe(boom)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if defined?(::Grape)
|
63
|
+
require 'oboe/inst/rack'
|
64
|
+
|
65
|
+
Oboe.logger.info "[oboe/loading] Instrumenting Grape" if Oboe::Config[:verbose]
|
66
|
+
|
67
|
+
Oboe::Loading.load_access_key
|
68
|
+
Oboe::Inst.load_instrumentation
|
69
|
+
|
70
|
+
::Oboe::Util.send_extend(::Grape::API, ::Oboe::Grape::API)
|
71
|
+
::Oboe::Util.send_include(::Grape::Endpoint, ::Oboe::Grape::Endpoint)
|
72
|
+
::Oboe::Util.send_include(::Grape::Middleware::Error, ::Oboe::Grape::Middleware::Error)
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2014 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module PadrinoInst
|
6
|
+
module Routing
|
7
|
+
def self.included(klass)
|
8
|
+
::Oboe::Util.method_alias(klass, :dispatch!, ::Padrino::Routing)
|
9
|
+
end
|
10
|
+
|
11
|
+
def dispatch_with_oboe
|
12
|
+
if Oboe.tracing?
|
13
|
+
report_kvs = {}
|
14
|
+
|
15
|
+
# Fall back to the raw tracing API so we can pass KVs
|
16
|
+
# back on exit (a limitation of the Oboe::API.trace
|
17
|
+
# block method) This removes the need for an info
|
18
|
+
# event to send additonal KVs
|
19
|
+
::Oboe::API.log_entry('padrino', {})
|
20
|
+
|
21
|
+
begin
|
22
|
+
r = dispatch_without_oboe
|
23
|
+
|
24
|
+
# Report Controller/Action as best possible
|
25
|
+
if request.controller and not request.controller.empty?
|
26
|
+
report_kvs[:Controller] = request.controller
|
27
|
+
else
|
28
|
+
report_kvs[:Controller] = self.class
|
29
|
+
end
|
30
|
+
|
31
|
+
report_kvs[:Action] = request.action
|
32
|
+
r
|
33
|
+
ensure
|
34
|
+
::Oboe::API.log_exit('padrino', report_kvs)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
dispatch_without_oboe
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if defined?(::Padrino)
|
45
|
+
# This instrumentation is a superset of the Sinatra instrumentation similar
|
46
|
+
# to how Padrino is a superset of Sinatra itself.
|
47
|
+
::Oboe.logger.info "[oboe/loading] Instrumenting Padrino" if Oboe::Config[:verbose]
|
48
|
+
|
49
|
+
require 'oboe/frameworks/padrino/templates'
|
50
|
+
|
51
|
+
Padrino.after_load do
|
52
|
+
::Oboe.logger = ::Padrino.logger if ::Padrino.respond_to?(:logger)
|
53
|
+
::Oboe::Loading.load_access_key
|
54
|
+
::Oboe::Inst.load_instrumentation
|
55
|
+
|
56
|
+
::Oboe::Util.send_include(::Padrino::Routing::InstanceMethods, ::Oboe::PadrinoInst::Routing)
|
57
|
+
if defined?(::Padrino::Rendering)
|
58
|
+
::Oboe::Util.send_include(::Padrino::Rendering::InstanceMethods, ::Oboe::PadrinoInst::Rendering)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Report __Init after fork when in Heroku
|
62
|
+
Oboe::API.report_init unless Oboe.heroku?
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module PadrinoInst
|
6
|
+
module Rendering
|
7
|
+
def self.included(klass)
|
8
|
+
::Oboe::Util.method_alias(klass, :render, ::Padrino::Rendering)
|
9
|
+
end
|
10
|
+
|
11
|
+
def render_with_oboe(engine, data=nil, options={}, locals={}, &block)
|
12
|
+
unless Oboe.tracing?
|
13
|
+
render_without_oboe(engine, data, options, locals, &block)
|
14
|
+
else
|
15
|
+
report_kvs = {}
|
16
|
+
|
17
|
+
if data
|
18
|
+
report_kvs[:engine] = engine
|
19
|
+
report_kvs[:template] = data
|
20
|
+
else
|
21
|
+
report_kvs[:template] = engine
|
22
|
+
end
|
23
|
+
|
24
|
+
if Oboe.tracing_layer_op?('render')
|
25
|
+
# For recursive calls to :render (for sub-partials and layouts),
|
26
|
+
# use method profiling.
|
27
|
+
begin
|
28
|
+
report_kvs[:FunctionName] = :render
|
29
|
+
report_kvs[:Class] = :Rendering
|
30
|
+
report_kvs[:Module] = 'Padrino'
|
31
|
+
report_kvs[:File] = __FILE__
|
32
|
+
report_kvs[:LineNumber] = __LINE__
|
33
|
+
rescue StandardError => e
|
34
|
+
::Oboe.logger.debug e.message
|
35
|
+
::Oboe.logger.debug e.backtrace.join(", ")
|
36
|
+
end
|
37
|
+
|
38
|
+
Oboe::API.profile(report_kvs[:template], report_kvs, false) do
|
39
|
+
render_without_oboe(engine, data, options, locals, &block)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
# Fall back to the raw tracing API so we can pass KVs
|
43
|
+
# back on exit (a limitation of the Oboe::API.trace
|
44
|
+
# block method) This removes the need for an info
|
45
|
+
# event to send additonal KVs
|
46
|
+
::Oboe::API.log_entry('render', {}, 'render')
|
47
|
+
|
48
|
+
begin
|
49
|
+
render_without_oboe(engine, data, options, locals, &block)
|
50
|
+
ensure
|
51
|
+
::Oboe::API.log_exit('render', report_kvs)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|