oboe 2.1.4 → 2.2.0
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.
- data/CHANGELOG +27 -17
- data/lib/oboe/api.rb +1 -0
- data/lib/oboe/api/layerinit.rb +6 -6
- data/lib/oboe/api/profiling.rb +47 -0
- data/lib/oboe/config.rb +32 -0
- data/lib/oboe/frameworks/rails.rb +0 -2
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +34 -2
- data/lib/oboe/frameworks/rails/inst/action_view.rb +29 -165
- 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 +5 -279
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +92 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +55 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +57 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +105 -0
- data/lib/oboe/inst/dalli.rb +5 -3
- data/lib/oboe/inst/rack.rb +17 -9
- data/lib/oboe/loading.rb +0 -36
- data/lib/oboe/ruby.rb +0 -1
- data/lib/oboe/version.rb +2 -2
- data/lib/rails/generators/oboe/install_generator.rb +15 -7
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +15 -5
- data/oboe.gemspec +0 -10
- metadata +14 -14
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (c) 2013 by AppNeta
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module Inst
|
6
|
+
module ConnectionAdapters
|
7
|
+
|
8
|
+
module Mysql2Adapter
|
9
|
+
include Oboe::Inst::ConnectionAdapters::Utils
|
10
|
+
|
11
|
+
def self.included(cls)
|
12
|
+
cls.class_eval do
|
13
|
+
if ::Rails::VERSION::MAJOR == 2 or (::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR == 0)
|
14
|
+
if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :execute
|
15
|
+
alias execute_without_oboe execute
|
16
|
+
alias execute execute_with_oboe
|
17
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
18
|
+
end
|
19
|
+
else
|
20
|
+
if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :exec_insert
|
21
|
+
alias exec_insert_without_oboe exec_insert
|
22
|
+
alias exec_insert exec_insert_with_oboe
|
23
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
24
|
+
end
|
25
|
+
|
26
|
+
# In Rails 3.1, exec_query was defined as a private method
|
27
|
+
if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :exec_query or
|
28
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter::private_method_defined? :exec_query
|
29
|
+
alias exec_query_without_oboe exec_query
|
30
|
+
alias exec_query exec_query_with_oboe
|
31
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
32
|
+
end
|
33
|
+
|
34
|
+
if ActiveRecord::ConnectionAdapters::Mysql2Adapter::method_defined? :exec_delete
|
35
|
+
alias exec_delete_without_oboe exec_delete
|
36
|
+
alias exec_delete exec_delete_with_oboe
|
37
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end # Mysql2Adapter
|
43
|
+
|
44
|
+
module FlavorInitializers
|
45
|
+
def self.mysql2
|
46
|
+
Oboe.logger.info "[oboe/loading] Instrumenting activerecord mysql2adapter" if Oboe::Config[:verbose]
|
47
|
+
::ActiveRecord::ConnectionAdapters::Mysql2Adapter.module_eval do
|
48
|
+
include Oboe::Inst::ConnectionAdapters::Mysql2Adapter
|
49
|
+
end if defined?(::ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2013 by AppNeta
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module Inst
|
6
|
+
module ConnectionAdapters
|
7
|
+
module FlavorInitializers
|
8
|
+
def self.oracle
|
9
|
+
Oboe.logger.info "[oboe/loading] Instrumenting activerecord oracleenhancedadapter" if Oboe::Config[:verbose]
|
10
|
+
::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.module_eval do
|
11
|
+
include Oboe::Inst::ConnectionAdapters
|
12
|
+
end if defined?(::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (c) 2013 by AppNeta
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module Inst
|
6
|
+
module ConnectionAdapters
|
7
|
+
|
8
|
+
module PostgreSQLAdapter
|
9
|
+
include Oboe::Inst::ConnectionAdapters::Utils
|
10
|
+
|
11
|
+
def self.included(cls)
|
12
|
+
cls.class_eval do
|
13
|
+
if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :exec_query
|
14
|
+
alias exec_query_without_oboe exec_query
|
15
|
+
alias exec_query exec_query_with_oboe
|
16
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
17
|
+
end
|
18
|
+
|
19
|
+
if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :exec_delete
|
20
|
+
alias exec_delete_without_oboe exec_delete
|
21
|
+
alias exec_delete exec_delete_with_oboe
|
22
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end # PostgreSQLAdapter
|
27
|
+
|
28
|
+
module LegacyPostgreSQLAdapter
|
29
|
+
include Oboe::Inst::ConnectionAdapters::Utils
|
30
|
+
|
31
|
+
def self.included(cls)
|
32
|
+
cls.class_eval do
|
33
|
+
if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::method_defined? :execute
|
34
|
+
alias execute_without_oboe execute
|
35
|
+
alias execute execute_with_oboe
|
36
|
+
else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end # LegacyPostgreSQLAdapter
|
41
|
+
|
42
|
+
module FlavorInitializers
|
43
|
+
def self.postgresql
|
44
|
+
Oboe.logger.info "[oboe/loading] Instrumenting activerecord postgresqladapter" if Oboe::Config[:verbose]
|
45
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.module_eval do
|
46
|
+
if (::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR > 0) or ::Rails::VERSION::MAJOR == 4
|
47
|
+
include Oboe::Inst::ConnectionAdapters::PostgreSQLAdapter
|
48
|
+
else
|
49
|
+
include Oboe::Inst::ConnectionAdapters::LegacyPostgreSQLAdapter
|
50
|
+
end
|
51
|
+
end if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# Copyright (c) 2013 by AppNeta
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module Oboe
|
5
|
+
module Inst
|
6
|
+
module ConnectionAdapters
|
7
|
+
module Utils
|
8
|
+
def extract_trace_details(sql, name = nil)
|
9
|
+
opts = {}
|
10
|
+
|
11
|
+
begin
|
12
|
+
opts[:Query] = sql.to_s
|
13
|
+
opts[:Name] = name.to_s if name
|
14
|
+
opts[:Backtrace] = Oboe::API.backtrace
|
15
|
+
|
16
|
+
if ::Rails::VERSION::MAJOR == 2
|
17
|
+
config = ::Rails.configuration.database_configuration[::Rails.env]
|
18
|
+
else
|
19
|
+
config = ::Rails.application.config.database_configuration[::Rails.env]
|
20
|
+
end
|
21
|
+
|
22
|
+
opts[:Database] = config["database"] if config.has_key?("database")
|
23
|
+
opts[:RemoteHost] = config["host"] if config.has_key?("host")
|
24
|
+
opts[:Flavor] = config["adapter"] if config.has_key?("adapter")
|
25
|
+
rescue Exception => e
|
26
|
+
end
|
27
|
+
|
28
|
+
return opts || {}
|
29
|
+
end
|
30
|
+
|
31
|
+
# We don't want to trace framework caches. Only instrument SQL that
|
32
|
+
# directly hits the database.
|
33
|
+
def ignore_payload?(name)
|
34
|
+
%w(SCHEMA EXPLAIN CACHE).include? name.to_s or (name and name.to_sym == :skip_logging)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cfg
|
38
|
+
@config
|
39
|
+
end
|
40
|
+
|
41
|
+
def execute_with_oboe(sql, name = nil)
|
42
|
+
if Oboe.tracing? and !ignore_payload?(name)
|
43
|
+
|
44
|
+
opts = extract_trace_details(sql, name)
|
45
|
+
Oboe::API.trace('activerecord', opts || {}) do
|
46
|
+
execute_without_oboe(sql, name)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
execute_without_oboe(sql, name)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def exec_query_with_oboe(sql, name = nil, binds = [])
|
54
|
+
if Oboe.tracing? and !ignore_payload?(name)
|
55
|
+
|
56
|
+
opts = extract_trace_details(sql, name)
|
57
|
+
Oboe::API.trace('activerecord', opts || {}) do
|
58
|
+
exec_query_without_oboe(sql, name, binds)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
exec_query_without_oboe(sql, name, binds)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def exec_delete_with_oboe(sql, name = nil, binds = [])
|
66
|
+
if Oboe.tracing? and !ignore_payload?(name)
|
67
|
+
|
68
|
+
opts = extract_trace_details(sql, name)
|
69
|
+
Oboe::API.trace('activerecord', opts || {}) do
|
70
|
+
exec_delete_without_oboe(sql, name, binds)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
exec_delete_without_oboe(sql, name, binds)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def exec_insert_with_oboe(sql, name = nil, binds = [], *args)
|
78
|
+
if Oboe.tracing? and !ignore_payload?(name)
|
79
|
+
|
80
|
+
opts = extract_trace_details(sql, name)
|
81
|
+
Oboe::API.trace('activerecord', opts || {}) do
|
82
|
+
exec_insert_without_oboe(sql, name, binds, *args)
|
83
|
+
end
|
84
|
+
else
|
85
|
+
exec_insert_without_oboe(sql, name, binds, *args)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def begin_db_transaction_with_oboe()
|
90
|
+
if Oboe.tracing?
|
91
|
+
opts = {}
|
92
|
+
|
93
|
+
opts[:Query] = "BEGIN"
|
94
|
+
Oboe::API.trace('activerecord', opts || {}) do
|
95
|
+
begin_db_transaction_without_oboe()
|
96
|
+
end
|
97
|
+
else
|
98
|
+
begin_db_transaction_without_oboe()
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end # Utils
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
data/lib/oboe/inst/dalli.rb
CHANGED
@@ -22,21 +22,23 @@ module Oboe
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def perform_with_oboe(
|
25
|
+
def perform_with_oboe(*all_args, &blk)
|
26
|
+
op, key, *args = *all_args
|
27
|
+
|
26
28
|
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
|
27
29
|
opts = {}
|
28
30
|
opts[:KVOp] = op
|
29
31
|
opts[:KVKey] = key
|
30
32
|
|
31
33
|
Oboe::API.trace('memcache', opts || {}) do
|
32
|
-
result = perform_without_oboe(
|
34
|
+
result = perform_without_oboe(*all_args, &blk)
|
33
35
|
if op == :get and key.class == String
|
34
36
|
Oboe::API.log('memcache', 'info', { :KVHit => memcache_hit?(result) })
|
35
37
|
end
|
36
38
|
result
|
37
39
|
end
|
38
40
|
else
|
39
|
-
perform_without_oboe(
|
41
|
+
perform_without_oboe(*all_args, &blk)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
data/lib/oboe/inst/rack.rb
CHANGED
@@ -15,16 +15,24 @@ module Oboe
|
|
15
15
|
|
16
16
|
begin
|
17
17
|
xtrace = env['HTTP_X_TRACE'] if env.is_a?(Hash)
|
18
|
-
|
18
|
+
|
19
19
|
req = ::Rack::Request.new(env)
|
20
|
-
report_kvs[:SampleRate]
|
21
|
-
report_kvs[
|
22
|
-
report_kvs['HTTP-
|
23
|
-
report_kvs['
|
24
|
-
report_kvs[
|
25
|
-
report_kvs[
|
26
|
-
report_kvs[
|
27
|
-
report_kvs[
|
20
|
+
report_kvs[:SampleRate] = Oboe::Config[:sample_rate]
|
21
|
+
report_kvs[:SampleSource] = Oboe::Config[:sample_source]
|
22
|
+
report_kvs['HTTP-Host'] = req.host
|
23
|
+
report_kvs['Port'] = req.port
|
24
|
+
report_kvs['Proto'] = req.scheme
|
25
|
+
report_kvs['Query-String'] = req.query_string unless req.query_string.blank?
|
26
|
+
report_kvs[:URL] = req.path
|
27
|
+
report_kvs[:Method] = req.request_method
|
28
|
+
report_kvs['AJAX'] = true if req.xhr?
|
29
|
+
report_kvs['ClientIP'] = req.ip
|
30
|
+
|
31
|
+
report_kvs['TV-Meta'] = env['HTTP_X-TV-META'] if env.has_key?('HTTP_X-TV-META')
|
32
|
+
report_kvs['Forwarded-For'] = env['HTTP_X-FORWARDED-FOR'] if env.has_key?('HTTP_X-FORWARDED-FOR')
|
33
|
+
report_kvs['Forwarded-Host'] = env['HTTP_X-FORWARDED-HOST'] if env.has_key?('HTTP_X-FORWARDED-HOST')
|
34
|
+
report_kvs['Forwarded-Proto'] = env['HTTP_X-FORWARDED-PROTO'] if env.has_key?('HTTP_X-FORWARDED-PROTO')
|
35
|
+
report_kvs['Forwarded-Port'] = env['HTTP_X-FORWARDED-PORT'] if env.has_key?('HTTP_X-FORWARDED-PORT')
|
28
36
|
rescue
|
29
37
|
# Discard any potential exceptions. Report whatever we can.
|
30
38
|
end
|
data/lib/oboe/loading.rb
CHANGED
@@ -109,42 +109,6 @@ module Oboe
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
113
|
-
##
|
114
|
-
# Update liboboe with the configured tracing mode
|
115
|
-
#
|
116
|
-
def self.set_tracing_mode
|
117
|
-
# If we are in Heroku, let the oboe-heroku gem configure tracing mode
|
118
|
-
# itself as the requirements are slightly different.
|
119
|
-
return if defined?(OboeHeroku)
|
120
|
-
|
121
|
-
# OBOE_TRACE_NEVER 0
|
122
|
-
# OBOE_TRACE_ALWAYS 1
|
123
|
-
# OBOE_TRACE_THROUGH 2
|
124
|
-
|
125
|
-
if defined?(Oboe::Config)
|
126
|
-
|
127
|
-
case Oboe::Config[:tracing_mode].to_s.downcase.to_sym
|
128
|
-
when :never
|
129
|
-
# OBOE_TRACE_NEVER
|
130
|
-
Oboe.logger.debug "Setting liboboe TracingMode to OBOE_TRACE_NEVER"
|
131
|
-
Oboe::Context.setTracingMode(0)
|
132
|
-
when :always
|
133
|
-
# OBOE_TRACE_ALWAYS
|
134
|
-
Oboe.logger.debug "Setting liboboe TracingMode to OBOE_TRACE_ALWAYS"
|
135
|
-
Oboe::Context.setTracingMode(1)
|
136
|
-
else
|
137
|
-
# OBOE_TRACE_THROUGH
|
138
|
-
Oboe.logger.debug "Setting liboboe TracingMode to OBOE_TRACE_THROUGH"
|
139
|
-
Oboe::Context.setTracingMode(2)
|
140
|
-
end
|
141
|
-
else
|
142
|
-
# OBOE_TRACE_THROUGH
|
143
|
-
Oboe.logger.debug "Setting liboboe TracingMode to OBOE_TRACE_THROUGH (no Oboe::Config?)"
|
144
|
-
Oboe::Context.setTracingMode(2)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
112
|
end
|
149
113
|
end
|
150
114
|
|
data/lib/oboe/ruby.rb
CHANGED
data/lib/oboe/version.rb
CHANGED
@@ -11,19 +11,27 @@ module Oboe
|
|
11
11
|
@verbose = 'false'
|
12
12
|
|
13
13
|
say ""
|
14
|
-
say set_color "Welcome to the
|
14
|
+
say set_color "Welcome to the TraceView Ruby instrumentation setup.", :green, :bold
|
15
15
|
say ""
|
16
16
|
say "To instrument your Rails application, you have the option to setup sampling strategies here."
|
17
17
|
say ""
|
18
|
+
say set_color "Documentation Links", :magenta
|
19
|
+
say "-------------------"
|
20
|
+
say ""
|
21
|
+
say "Details on configuring your sampling rate:"
|
22
|
+
say "http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling"
|
23
|
+
say ""
|
18
24
|
say "More information on instrumenting Ruby applications can be found here:"
|
19
|
-
say "http://support.
|
25
|
+
say "http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps"
|
20
26
|
while true do
|
21
27
|
say ""
|
22
|
-
say set_color "Tracing Mode", :
|
28
|
+
say set_color "Tracing Mode", :magenta
|
23
29
|
say "------------"
|
24
|
-
say "
|
25
|
-
say "
|
26
|
-
say "
|
30
|
+
say "Tracing Mode determines when traces should be initiated for incoming requests. Valid"
|
31
|
+
say "options are #{set_color "always", :yellow}, #{set_color "through", :yellow} (when using an instrumented Apache or Nginx) and #{set_color "never", :yellow}."
|
32
|
+
say ""
|
33
|
+
say "If you're not using an instrumented Apache or Nginx, set this directive to #{set_color "always", :yellow} in"
|
34
|
+
say "order to initiate tracing from Ruby."
|
27
35
|
say ""
|
28
36
|
user_tracing_mode = ask set_color "* Tracing Mode? [through]:", :yellow
|
29
37
|
user_tracing_mode.downcase!
|
@@ -59,7 +67,7 @@ module Oboe
|
|
59
67
|
say ""
|
60
68
|
say "You can change these values in the future by modifying config/initializers/oboe.rb"
|
61
69
|
say ""
|
62
|
-
say "Thanks! Creating
|
70
|
+
say "Thanks! Creating the TraceView initializer..."
|
63
71
|
say ""
|
64
72
|
|
65
73
|
template "oboe_initializer.rb", "config/initializers/oboe.rb"
|
@@ -1,8 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# AppNeta TraceView Initializer (the oboe gem)
|
2
|
+
# http://www.appneta.com/products/traceview/
|
3
|
+
#
|
4
|
+
# Details on configuring your sampling rate:
|
5
|
+
# http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling
|
6
|
+
#
|
7
|
+
# More information on instrumenting Ruby applications can be found here:
|
8
|
+
# http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps
|
9
|
+
|
10
|
+
if defined?(Oboe::Config)
|
11
|
+
# Tracing Mode determines when traces should be initiated for incoming requests. Valid
|
12
|
+
# options are always, through (when using an instrumented Apache or Nginx) and never.
|
13
|
+
#
|
14
|
+
# If you're not using an instrumented Apache or Nginx, set this directive to always in
|
15
|
+
# order to initiate tracing from Ruby.
|
6
16
|
Oboe::Config[:tracing_mode] = '<%= @tracing_mode %>'
|
7
17
|
<% if ['through', 'never'].include?(@tracing_mode) %>
|
8
18
|
# sample_rate is a value from 0 - 1m indicating the fraction of requests per million to trace
|
data/oboe.gemspec
CHANGED
@@ -16,14 +16,4 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = Dir.glob("{spec}/**/*.rb")
|
17
17
|
s.add_development_dependency 'rake'
|
18
18
|
s.add_development_dependency 'rspec'
|
19
|
-
|
20
|
-
s.post_install_message = "
|
21
|
-
|
22
|
-
This oboe gem requires updated AppNeta liboboe (>= 1.1.1) and
|
23
|
-
tracelytics-java-agent packages (if using JRuby). Make sure to update all
|
24
|
-
of your hosts or this gem will just sit in the corner and weep quietly.
|
25
|
-
|
26
|
-
- Your Friendly AppNeta TraceView Team
|
27
|
-
|
28
|
-
"
|
29
19
|
end
|