oboe 2.2.0 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -99,8 +99,8 @@ module Oboe
99
99
  # Assure defaults since SWIG enforces Strings
100
100
  opts[:layer] ||= ''
101
101
  opts[:xtrace] ||= ''
102
- opts['X-TV-Meta'] ||= ''
103
- Java::ComTracelyticsJoboeSettingsReader.shouldTraceRequest(opts[:layer], opts[:xtrace], opts['X-TV-Meta'])
102
+ opts['TV-Meta'] ||= ''
103
+ Java::ComTracelyticsJoboeSettingsReader.shouldTraceRequest(opts[:layer], opts[:xtrace], opts['TV-Meta'])
104
104
  end
105
105
 
106
106
  def self.through?
@@ -17,6 +17,7 @@ begin
17
17
  end
18
18
  end
19
19
  require 'oboe/logger'
20
+ require 'oboe/util'
20
21
  require 'oboe/config'
21
22
  require 'oboe/loading'
22
23
  require 'method_profiling'
@@ -27,7 +28,10 @@ begin
27
28
  require 'oboe/frameworks/rails' if defined?(::Rails)
28
29
 
29
30
  rescue LoadError
30
- $stderr.puts "Unsupported Tracelytics environment (no libs). Going No-op."
31
+ $stderr.puts "=============================================================="
32
+ $stderr.puts "Missing TraceView libraries. Tracing disabled."
33
+ $stderr.puts "See: https://support.tv.appneta.com/solution/articles/137973"
34
+ $stderr.puts "=============================================================="
31
35
  rescue Exception => e
32
36
  $stderr.puts "[oboe/error] Problem loading: #{e.inspect}"
33
37
  end
@@ -42,6 +42,11 @@ module Oboe
42
42
  # Setup an empty host blacklist (see: Oboe::API::Util.blacklisted?)
43
43
  @@config[:blacklist] = []
44
44
 
45
+ # The oboe Ruby client has the ability to sanitize query literals
46
+ # from SQL statements. By default this is disabled. Enable to
47
+ # avoid collecting and reporting query literals to TraceView.
48
+ @@config[:sanitize_sql] = false
49
+
45
50
  update!(data)
46
51
 
47
52
  # For Initialization, mark this as the default SampleRate
@@ -65,14 +70,21 @@ module Oboe
65
70
  # When setting SampleRate, note that it's been manually set
66
71
  # OBOE_SAMPLE_RATE_SOURCE_FILE == 1
67
72
  @@config[:sample_source] = 1
73
+
74
+ unless value.is_a?(Integer) or value.is_a?(Float)
75
+ raise "oboe :sample_rate must be a number between 1 and 1000000 (1m)"
76
+ end
68
77
 
69
78
  # Validate :sample_rate value
70
79
  unless value.between?(1, 1e6)
71
80
  raise "oboe :sample_rate must be between 1 and 1000000 (1m)"
72
81
  end
73
82
 
83
+ # Assure value is an integer
84
+ @@config[key.to_sym] = value.to_i
85
+
74
86
  # Update liboboe with the new SampleRate value
75
- Oboe::Context.setDefaultSampleRate(value)
87
+ Oboe::Context.setDefaultSampleRate(value.to_i)
76
88
  end
77
89
 
78
90
  # Update liboboe if updating :tracing_mode
@@ -104,7 +116,7 @@ end
104
116
  config = {
105
117
  :tracing_mode => "through",
106
118
  :reporter_host => "127.0.0.1",
107
- :sample_rate => 1000000,
119
+ :sample_rate => 300000,
108
120
  :verbose => false }
109
121
 
110
122
  Oboe::Config.initialize(config)
@@ -17,7 +17,8 @@ if Oboe::Config[:active_record][:enabled]
17
17
  Oboe::Inst::ConnectionAdapters::FlavorInitializers.oracle if adapter == "oracleenhanced"
18
18
 
19
19
  rescue Exception => e
20
- Oboe.logger.error "[oboe/error] Oboe/ActiveRecord error: #{e.message}" if Oboe::Config[:verbose]
20
+ Oboe.logger.error "[oboe/error] Oboe/ActiveRecord error: #{e.inspect}"
21
+ Oboe.logger.debug e.backtrace.join("\n")
21
22
  end
22
23
  end
23
24
  # vim:set expandtab:tabstop=2
@@ -4,88 +4,39 @@
4
4
  module Oboe
5
5
  module Inst
6
6
  module ConnectionAdapters
7
+ module FlavorInitializers
8
+ def self.mysql
9
+ Oboe.logger.info "[oboe/loading] Instrumenting activerecord mysqladapter" if Oboe::Config[:verbose]
7
10
 
8
- module AbstractMysqlAdapter
9
- include Oboe::Inst::ConnectionAdapters::Utils
10
-
11
- def self.included(cls)
12
- cls.class_eval do
13
- if ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter::method_defined? :execute
14
- alias execute_without_oboe execute
15
- alias execute execute_with_oboe
16
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
17
- end
18
- end
19
- end
20
- end # AbstractMysqlAdapter
11
+ # ActiveRecord 3.2 and higher
12
+ if (::ActiveRecord::VERSION::MAJOR == 3 and ::ActiveRecord::VERSION::MINOR >= 2) or
13
+ ::ActiveRecord::VERSION::MAJOR == 4
21
14
 
22
- module MysqlAdapter
23
- include Oboe::Inst::ConnectionAdapters::Utils
24
-
25
- def self.included(cls)
26
- cls.class_eval do
27
- if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_query
28
- alias exec_query_without_oboe exec_query
29
- alias exec_query exec_query_with_oboe
30
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
31
- end
32
- end
33
- end
34
- end # MysqlAdapter
15
+ # AbstractMysqlAdapter
16
+ Oboe::Util.send_include(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter,
17
+ Oboe::Inst::ConnectionAdapters::Utils)
18
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter, :execute)
35
19
 
36
- module LegacyMysqlAdapter
37
- include Oboe::Inst::ConnectionAdapters::Utils
38
-
39
- def self.included(cls)
40
- cls.class_eval do
41
- if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :execute
42
- alias execute_without_oboe execute
43
- alias execute execute_with_oboe
44
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
45
- end
46
-
47
- if ::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR == 1
48
- if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :begin_db_transaction
49
- alias begin_db_transaction_without_oboe begin_db_transaction
50
- alias begin_db_transaction begin_db_transaction_with_oboe
51
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
52
- end
53
- end
20
+ # MysqlAdapter
21
+ Oboe::Util.send_include(::ActiveRecord::ConnectionAdapters::MysqlAdapter,
22
+ Oboe::Inst::ConnectionAdapters::Utils)
23
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :exec_query)
24
+
25
+ else
26
+ # ActiveRecord 3.1 and below
54
27
 
55
- if (::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR > 0) or ::Rails::VERSION::MAJOR == 4
56
- if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_query
57
- alias exec_query_without_oboe exec_query
58
- alias exec_query exec_query_with_oboe
59
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
60
- end
28
+ # MysqlAdapter
29
+ Oboe::Util.send_include(::ActiveRecord::ConnectionAdapters::MysqlAdapter,
30
+ Oboe::Inst::ConnectionAdapters::Utils)
31
+
32
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :execute)
61
33
 
62
- if ActiveRecord::ConnectionAdapters::MysqlAdapter::method_defined? :exec_delete
63
- alias exec_delete_without_oboe exec_delete
64
- alias exec_delete exec_delete_with_oboe
65
- else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument activerecord layer. Partial traces may occur."
66
- end
34
+ if ::ActiveRecord::VERSION::MAJOR == 3 and ::ActiveRecord::VERSION::MINOR == 1
35
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :begin_db_transaction)
36
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :exec_delete)
67
37
  end
68
38
  end
69
39
  end
70
- end # LegacyMysqlAdapter
71
-
72
- module FlavorInitializers
73
- def self.mysql
74
- Oboe.logger.info "[oboe/loading] Instrumenting activerecord mysqladapter" if Oboe::Config[:verbose]
75
- if (::Rails::VERSION::MAJOR == 3 and ::Rails::VERSION::MINOR > 1) or ::Rails::VERSION::MAJOR == 4
76
- ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.module_eval do
77
- include Oboe::Inst::ConnectionAdapters::AbstractMysqlAdapter
78
- end if defined?(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter)
79
-
80
- ::ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
81
- include Oboe::Inst::ConnectionAdapters::MysqlAdapter
82
- end if defined?(::ActiveRecord::ConnectionAdapters::MysqlAdapter)
83
- else
84
- ::ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
85
- include Oboe::Inst::ConnectionAdapters::LegacyMysqlAdapter
86
- end if defined?(::ActiveRecord::ConnectionAdapters::MysqlAdapter)
87
- end
88
- end
89
40
  end
90
41
  end
91
42
  end
@@ -4,52 +4,25 @@
4
4
  module Oboe
5
5
  module Inst
6
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
7
  module FlavorInitializers
45
8
  def self.mysql2
46
9
  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)
10
+
11
+ Oboe::Util.send_include(::ActiveRecord::ConnectionAdapters::Mysql2Adapter,
12
+ Oboe::Inst::ConnectionAdapters::Utils)
13
+
14
+ if (::ActiveRecord::VERSION::MAJOR == 3 and ::ActiveRecord::VERSION::MINOR == 0) or
15
+ ::ActiveRecord::VERSION::MAJOR == 2
16
+ # ActiveRecord 3.0 and prior
17
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :execute)
18
+ else
19
+ # ActiveRecord 3.1 and above
20
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_insert)
21
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_query)
22
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_delete)
23
+ end
50
24
  end
51
25
  end
52
-
53
26
  end
54
27
  end
55
28
  end
@@ -4,54 +4,27 @@
4
4
  module Oboe
5
5
  module Inst
6
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
7
  module FlavorInitializers
43
8
  def self.postgresql
9
+
44
10
  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)
11
+
12
+ Oboe::Util.send_include(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter,
13
+ Oboe::Inst::ConnectionAdapters::Utils)
14
+
15
+ if (::ActiveRecord::VERSION::MAJOR == 3 and ::ActiveRecord::VERSION::MINOR > 0) or
16
+ ::ActiveRecord::VERSION::MAJOR == 4
17
+
18
+ # ActiveRecord 3.1 and up
19
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :exec_query)
20
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :exec_delete)
21
+
22
+ else
23
+ # ActiveRecord 3.0 and prior
24
+ Oboe::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :execute)
25
+ end
52
26
  end
53
27
  end
54
-
55
28
  end
56
29
  end
57
30
  end
@@ -5,11 +5,28 @@ module Oboe
5
5
  module Inst
6
6
  module ConnectionAdapters
7
7
  module Utils
8
- def extract_trace_details(sql, name = nil)
8
+
9
+ def extract_trace_details(sql, name = nil, binds = [])
9
10
  opts = {}
10
11
 
11
12
  begin
12
- opts[:Query] = sql.to_s
13
+ if binds.empty?
14
+ # Raw SQL. Sanitize if requested
15
+ if Oboe::Config[:sanitize_sql]
16
+ opts[:Query] = sql.gsub(/\'[\s\S][^\']*\'/, '?')
17
+ else
18
+ opts[:Query] = sql.to_s
19
+ end
20
+ else
21
+ # We have bind parameters. Only report if :sanitize_sql isn't true
22
+ unless Oboe::Config[:sanitize_sql]
23
+ opts[:Query] = sql.to_s
24
+ opts[:QueryArgs] = binds.map { |col, val| type_cast(val, col) }
25
+ else
26
+ opts[:Query] = sql.gsub(/\'[\s\S][^\']*\'/, '?')
27
+ end
28
+ end
29
+
13
30
  opts[:Name] = name.to_s if name
14
31
  opts[:Backtrace] = Oboe::API.backtrace
15
32
 
@@ -23,6 +40,8 @@ module Oboe
23
40
  opts[:RemoteHost] = config["host"] if config.has_key?("host")
24
41
  opts[:Flavor] = config["adapter"] if config.has_key?("adapter")
25
42
  rescue Exception => e
43
+ Oboe.logger.debug "Exception raised capturing ActiveRecord KVs: #{e.inspect}"
44
+ Oboe.logger.debug e.backtrace.join("\n")
26
45
  end
27
46
 
28
47
  return opts || {}
@@ -31,12 +50,14 @@ module Oboe
31
50
  # We don't want to trace framework caches. Only instrument SQL that
32
51
  # directly hits the database.
33
52
  def ignore_payload?(name)
34
- %w(SCHEMA EXPLAIN CACHE).include? name.to_s or (name and name.to_sym == :skip_logging)
53
+ %w(SCHEMA EXPLAIN CACHE).include? name.to_s or
54
+ (name and name.to_sym == :skip_logging) or
55
+ name == "ActiveRecord::SchemaMigration Load"
35
56
  end
36
57
 
37
- def cfg
38
- @config
39
- end
58
+ #def cfg
59
+ # @config
60
+ #end
40
61
 
41
62
  def execute_with_oboe(sql, name = nil)
42
63
  if Oboe.tracing? and !ignore_payload?(name)
@@ -53,7 +74,7 @@ module Oboe
53
74
  def exec_query_with_oboe(sql, name = nil, binds = [])
54
75
  if Oboe.tracing? and !ignore_payload?(name)
55
76
 
56
- opts = extract_trace_details(sql, name)
77
+ opts = extract_trace_details(sql, name, binds)
57
78
  Oboe::API.trace('activerecord', opts || {}) do
58
79
  exec_query_without_oboe(sql, name, binds)
59
80
  end
@@ -65,7 +86,7 @@ module Oboe
65
86
  def exec_delete_with_oboe(sql, name = nil, binds = [])
66
87
  if Oboe.tracing? and !ignore_payload?(name)
67
88
 
68
- opts = extract_trace_details(sql, name)
89
+ opts = extract_trace_details(sql, name, binds)
69
90
  Oboe::API.trace('activerecord', opts || {}) do
70
91
  exec_delete_without_oboe(sql, name, binds)
71
92
  end
@@ -77,7 +98,7 @@ module Oboe
77
98
  def exec_insert_with_oboe(sql, name = nil, binds = [], *args)
78
99
  if Oboe.tracing? and !ignore_payload?(name)
79
100
 
80
- opts = extract_trace_details(sql, name)
101
+ opts = extract_trace_details(sql, name, binds)
81
102
  Oboe::API.trace('activerecord', opts || {}) do
82
103
  exec_insert_without_oboe(sql, name, binds, *args)
83
104
  end
@@ -21,15 +21,17 @@ Net::HTTP.class_eval do
21
21
  opts['RemoteProtocol'] = use_ssl? ? 'HTTPS' : 'HTTP'
22
22
  opts['RemoteHost'] = addr_port
23
23
  opts['ServiceArg'] = req.path
24
- opts['Method'] = req.method
24
+ opts['HTTPMethod'] = req.method
25
25
  opts['Blacklisted'] = true if blacklisted
26
26
 
27
- Oboe::API.log('net-http', 'info', opts)
28
27
  req['X-Trace'] = Oboe::Context.toString() unless blacklisted
29
28
  end
30
29
 
31
30
  resp = request_without_oboe(*args, &block)
32
31
 
32
+ opts['HTTPStatus'] = resp.code
33
+ Oboe::API.log('net-http', 'info', opts)
34
+
33
35
  unless blacklisted
34
36
  xtrace = resp.get_fields('X-Trace')
35
37
  if xtrace and xtrace.size and Oboe.tracing?
@@ -27,12 +27,12 @@ module Oboe
27
27
  report_kvs[:Method] = req.request_method
28
28
  report_kvs['AJAX'] = true if req.xhr?
29
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')
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')
36
36
  rescue
37
37
  # Discard any potential exceptions. Report whatever we can.
38
38
  end
@@ -0,0 +1,45 @@
1
+
2
+ module Oboe
3
+ module Util
4
+ class << self
5
+ ##
6
+ # oboe_alias
7
+ #
8
+ # Centralized utility method to alias a method on an arbitrary
9
+ # class or module.
10
+ #
11
+ def method_alias(cls, method, name=nil)
12
+ # Attempt to infer a contextual name if not indicated
13
+ #
14
+ # For example:
15
+ # ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.to_s.split(/::/).last
16
+ # => "AbstractMysqlAdapter"
17
+ #
18
+ begin
19
+ name ||= cls.to_s.split(/::/).last
20
+ rescue
21
+ end
22
+
23
+ if cls.method_defined? method.to_sym or cls.private_method_defined? method.to_sym
24
+ cls.class_eval do
25
+ alias_method "#{method}_without_oboe", "#{method}"
26
+ alias_method "#{method}", "#{method}_with_oboe"
27
+ end
28
+ else Oboe.logger.warn "[oboe/loading] Couldn't properly instrument #{name}. Partial traces may occur."
29
+ end
30
+ end
31
+
32
+ ##
33
+ # oboe_send_include
34
+ #
35
+ # Centralized utility method to send a include call for an
36
+ # arbitrary class
37
+ def send_include(target_cls, cls)
38
+ if defined?(target_cls)
39
+ target_cls.send(:include, cls)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
@@ -2,7 +2,7 @@ module Oboe
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 5
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -69,8 +69,8 @@ module Oboe
69
69
  # Assure defaults since SWIG enforces Strings
70
70
  opts[:layer] ||= ''
71
71
  opts[:xtrace] ||= ''
72
- opts['X-TV-Meta'] ||= ''
73
- Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['X-TV-Meta'])
72
+ opts['TV-Meta'] ||= ''
73
+ Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['TV-Meta'])
74
74
  end
75
75
 
76
76
  def through?
@@ -11,11 +11,11 @@ module Oboe
11
11
  @verbose = 'false'
12
12
 
13
13
  say ""
14
- say set_color "Welcome to the TraceView Ruby instrumentation setup.", :green, :bold
14
+ say shell.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
18
+ say shell.set_color "Documentation Links", :magenta
19
19
  say "-------------------"
20
20
  say ""
21
21
  say "Details on configuring your sampling rate:"
@@ -25,47 +25,28 @@ module Oboe
25
25
  say "http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps"
26
26
  while true do
27
27
  say ""
28
- say set_color "Tracing Mode", :magenta
28
+ say shell.set_color "Tracing Mode", :magenta
29
29
  say "------------"
30
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}."
31
+ say "options are #{shell.set_color "always", :yellow}, #{shell.set_color "through", :yellow} (when using an instrumented Apache or Nginx) and #{shell.set_color "never", :yellow}."
32
32
  say ""
33
- say "If you're not using an instrumented Apache or Nginx, set this directive to #{set_color "always", :yellow} in"
33
+ say "If you're not using an instrumented Apache or Nginx, set this directive to #{shell.set_color "always", :yellow} in"
34
34
  say "order to initiate tracing from Ruby."
35
35
  say ""
36
- user_tracing_mode = ask set_color "* Tracing Mode? [through]:", :yellow
36
+ user_tracing_mode = ask shell.set_color "* Tracing Mode? [through]:", :yellow
37
37
  user_tracing_mode.downcase!
38
38
 
39
39
  break if user_tracing_mode.blank?
40
40
  valid = ['always', 'through', 'never'].include?(user_tracing_mode)
41
- say set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
41
+ say shell.set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
42
42
  if valid
43
43
  @tracing_mode = user_tracing_mode
44
44
  break
45
45
  end
46
46
  end
47
47
 
48
- if @tracing_mode == "always"
49
- while true do
50
- say ""
51
- say set_color "Sampling Rate", :green
52
- say "-------------"
53
- 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%)."
54
- say ""
55
- user_sampling_rate = ask set_color "* Sampling Rate? [300000]:", :yellow
56
- break if user_sampling_rate.blank?
57
-
58
- valid = user_sampling_rate.to_i.between?(1, 1000000)
59
- say set_color "Sampling Rate must be a number between 1 and 1000000", :red, :bold unless valid
60
- if valid
61
- @sampling_rate = user_sampling_rate.to_i
62
- break
63
- end
64
- end
65
- end
66
-
67
48
  say ""
68
- say "You can change these values in the future by modifying config/initializers/oboe.rb"
49
+ say "You can change configuration values in the future by modifying config/initializers/oboe.rb"
69
50
  say ""
70
51
  say "Thanks! Creating the TraceView initializer..."
71
52
  say ""
@@ -2,10 +2,10 @@
2
2
  # http://www.appneta.com/products/traceview/
3
3
  #
4
4
  # Details on configuring your sampling rate:
5
- # http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling
5
+ # http://support.tv.appneta.com/support/solutions/articles/86336
6
6
  #
7
7
  # More information on instrumenting Ruby applications can be found here:
8
- # http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps
8
+ # http://support.tv.appneta.com/support/solutions/articles/86393
9
9
 
10
10
  if defined?(Oboe::Config)
11
11
  # Tracing Mode determines when traces should be initiated for incoming requests. Valid
@@ -14,13 +14,10 @@ if defined?(Oboe::Config)
14
14
  # If you're not using an instrumented Apache or Nginx, set this directive to always in
15
15
  # order to initiate tracing from Ruby.
16
16
  Oboe::Config[:tracing_mode] = '<%= @tracing_mode %>'
17
- <% if ['through', 'never'].include?(@tracing_mode) %>
17
+
18
18
  # sample_rate is a value from 0 - 1m indicating the fraction of requests per million to trace
19
19
  # Oboe::Config[:sample_rate] = <%= @sampling_rate %>
20
- <% else %>
21
- # sample_rate is a value from 0 - 1m indicating the fraction of requests per million to trace
22
- Oboe::Config[:sample_rate] = <%= @sampling_rate %>
23
- <% end %>
20
+
24
21
  # Verbose output of instrumentation initialization
25
22
  # Oboe::Config[:verbose] = <%= @verbose %>
26
23
 
@@ -38,6 +35,11 @@ if defined?(Oboe::Config)
38
35
  # Set to true to disable Resque argument logging (Default: false)
39
36
  # Oboe::Config[:resque][:log_args] = false
40
37
 
38
+ # The oboe Ruby client has the ability to sanitize query literals
39
+ # from SQL statements. By default this is disabled. Enable to
40
+ # avoid collecting and reporting query literals to TraceView.
41
+ # Oboe::Config[:sanitize_sql] = false
42
+
41
43
  #
42
44
  # Enabling/Disabling Instrumentation
43
45
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oboe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 0
10
- version: 2.2.0
9
+ - 5
10
+ version: 2.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tracelytics, Inc.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-09-03 00:00:00 Z
18
+ date: 2013-09-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake
@@ -111,6 +111,7 @@ files:
111
111
  - lib/oboe/loading.rb
112
112
  - lib/oboe/logger.rb
113
113
  - lib/oboe/ruby.rb
114
+ - lib/oboe/util.rb
114
115
  - lib/oboe/version.rb
115
116
  - lib/oboe_fu.rb
116
117
  - lib/oboe_metal.rb