oboe 2.7.1.7 → 2.7.2.fuchs1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +3 -3
- data/ext/oboe_metal/extconf.rb +11 -11
- data/lib/joboe_metal.rb +36 -42
- data/lib/oboe.rb +29 -26
- data/lib/oboe/api.rb +4 -0
- data/lib/oboe/api/layerinit.rb +7 -67
- data/lib/oboe/api/logging.rb +50 -28
- data/lib/oboe/api/memcache.rb +7 -5
- data/lib/oboe/api/profiling.rb +4 -4
- data/lib/oboe/api/tracing.rb +6 -5
- data/lib/oboe/api/util.rb +13 -9
- data/lib/oboe/base.rb +55 -16
- data/lib/oboe/config.rb +17 -15
- data/lib/oboe/frameworks/padrino.rb +0 -2
- data/lib/oboe/frameworks/padrino/templates.rb +5 -6
- data/lib/oboe/frameworks/rails.rb +0 -1
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -5
- data/lib/oboe/frameworks/rails/inst/action_view.rb +4 -4
- data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +4 -4
- data/lib/oboe/frameworks/rails/inst/action_view_30.rb +2 -2
- data/lib/oboe/frameworks/rails/inst/active_record.rb +5 -5
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +6 -6
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +18 -19
- data/lib/oboe/frameworks/sinatra.rb +4 -5
- data/lib/oboe/inst/cassandra.rb +17 -19
- data/lib/oboe/inst/dalli.rb +5 -5
- data/lib/oboe/inst/em-http-request.rb +13 -13
- data/lib/oboe/inst/faraday.rb +71 -0
- data/lib/oboe/inst/http.rb +4 -4
- data/lib/oboe/inst/memcache.rb +7 -10
- data/lib/oboe/inst/memcached.rb +7 -9
- data/lib/oboe/inst/mongo.rb +26 -28
- data/lib/oboe/inst/moped.rb +23 -24
- data/lib/oboe/inst/rack.rb +10 -11
- data/lib/oboe/inst/redis.rb +18 -20
- data/lib/oboe/inst/resque.rb +8 -9
- data/lib/oboe/instrumentation.rb +3 -0
- data/lib/oboe/loading.rb +19 -23
- data/lib/{method_profiling.rb → oboe/method_profiling.rb} +22 -8
- data/lib/oboe/ruby.rb +23 -3
- data/lib/oboe/support.rb +94 -0
- data/lib/oboe/thread_local.rb +9 -1
- data/lib/oboe/util.rb +90 -18
- data/lib/oboe/version.rb +5 -2
- data/lib/oboe/xtrace.rb +20 -24
- data/lib/oboe_metal.rb +16 -13
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +2 -0
- data/test/instrumentation/faraday_test.rb +142 -0
- data/test/instrumentation/moped_test.rb +2 -0
- data/test/minitest_helper.rb +0 -1
- data/test/support/config_test.rb +3 -1
- metadata +10 -5
data/lib/oboe/thread_local.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# Provides thread local storage for Oboe.
|
7
|
+
#
|
8
|
+
# Example usage:
|
9
|
+
# module OboeBase
|
10
|
+
# extend ::Oboe::ThreadLocal
|
11
|
+
# thread_local :layer_op
|
12
|
+
# end
|
5
13
|
module ThreadLocal
|
6
14
|
def thread_local(name)
|
7
15
|
key = "__#{self}_#{name}__".intern
|
@@ -10,7 +18,7 @@ module Oboe
|
|
10
18
|
Thread.current[key]
|
11
19
|
end
|
12
20
|
|
13
|
-
define_method(name.to_s +
|
21
|
+
define_method(name.to_s + '=') do |value|
|
14
22
|
Thread.current[key] = value
|
15
23
|
end
|
16
24
|
end
|
data/lib/oboe/util.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# Provides utility methods for use while in the business
|
7
|
+
# of instrumenting code
|
5
8
|
module Util
|
6
9
|
class << self
|
7
10
|
def contextual_name(cls)
|
@@ -11,10 +14,9 @@ module Oboe
|
|
11
14
|
# ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.to_s.split(/::/).last
|
12
15
|
# => "AbstractMysqlAdapter"
|
13
16
|
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
17
|
+
cls.to_s.split(/::/).last
|
18
|
+
rescue
|
19
|
+
cls
|
18
20
|
end
|
19
21
|
|
20
22
|
##
|
@@ -23,10 +25,10 @@ module Oboe
|
|
23
25
|
# Centralized utility method to alias a method on an arbitrary
|
24
26
|
# class or module.
|
25
27
|
#
|
26
|
-
def method_alias(cls, method, name=nil)
|
28
|
+
def method_alias(cls, method, name = nil)
|
27
29
|
name ||= contextual_name(cls)
|
28
30
|
|
29
|
-
if cls.method_defined?
|
31
|
+
if cls.method_defined?(method.to_sym) || cls.private_method_defined?(method.to_sym)
|
30
32
|
|
31
33
|
# Strip '!' or '?' from method if present
|
32
34
|
safe_method_name = method.to_s.chop if method.to_s =~ /\?$|\!$/
|
@@ -36,8 +38,8 @@ module Oboe
|
|
36
38
|
with_oboe = "#{safe_method_name}_with_oboe"
|
37
39
|
|
38
40
|
# Only alias if we haven't done so already
|
39
|
-
unless cls.method_defined?
|
40
|
-
cls.private_method_defined?
|
41
|
+
unless cls.method_defined?(without_oboe.to_sym) ||
|
42
|
+
cls.private_method_defined?(without_oboe.to_sym)
|
41
43
|
|
42
44
|
cls.class_eval do
|
43
45
|
alias_method without_oboe, "#{method}"
|
@@ -54,7 +56,7 @@ module Oboe
|
|
54
56
|
# Centralized utility method to alias a class method on an arbitrary
|
55
57
|
# class or module
|
56
58
|
#
|
57
|
-
def class_method_alias(cls, method, name=nil)
|
59
|
+
def class_method_alias(cls, method, name = nil)
|
58
60
|
name ||= contextual_name(cls)
|
59
61
|
|
60
62
|
if cls.singleton_methods.include? method.to_sym
|
@@ -81,9 +83,7 @@ module Oboe
|
|
81
83
|
# Centralized utility method to send an extend call for an
|
82
84
|
# arbitrary class
|
83
85
|
def send_extend(target_cls, cls)
|
84
|
-
if defined?(target_cls)
|
85
|
-
target_cls.send(:extend, cls)
|
86
|
-
end
|
86
|
+
target_cls.send(:extend, cls) if defined?(target_cls)
|
87
87
|
end
|
88
88
|
|
89
89
|
##
|
@@ -92,9 +92,7 @@ module Oboe
|
|
92
92
|
# Centralized utility method to send a include call for an
|
93
93
|
# arbitrary class
|
94
94
|
def send_include(target_cls, cls)
|
95
|
-
if defined?(target_cls)
|
96
|
-
target_cls.send(:include, cls)
|
97
|
-
end
|
95
|
+
target_cls.send(:include, cls) if defined?(target_cls)
|
98
96
|
end
|
99
97
|
|
100
98
|
##
|
@@ -104,7 +102,7 @@ module Oboe
|
|
104
102
|
# solely on filename)
|
105
103
|
#
|
106
104
|
def static_asset?(path)
|
107
|
-
|
105
|
+
(path =~ /\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|ttf|woff|svg|less)$/i)
|
108
106
|
end
|
109
107
|
|
110
108
|
##
|
@@ -112,7 +110,7 @@ module Oboe
|
|
112
110
|
#
|
113
111
|
# Even to my surprise, 'prettify' is a real word:
|
114
112
|
# transitive v. To make pretty or prettier, especially in a superficial or insubstantial way.
|
115
|
-
# from The American Heritage
|
113
|
+
# from The American Heritage Dictionary of the English Language, 4th Edition
|
116
114
|
#
|
117
115
|
# This method makes things 'purty' for reporting.
|
118
116
|
def prettify(x)
|
@@ -123,7 +121,81 @@ module Oboe
|
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
124
|
+
##
|
125
|
+
# build_report
|
126
|
+
#
|
127
|
+
# Internal: Build a hash of KVs that reports on the status of the
|
128
|
+
# running environment.
|
129
|
+
def build_report
|
130
|
+
platform_info = { '__Init' => 1 }
|
131
|
+
|
132
|
+
begin
|
133
|
+
platform_info['Force'] = true
|
134
|
+
platform_info['Ruby.Platform.Version'] = RUBY_PLATFORM
|
135
|
+
platform_info['Ruby.Version'] = RUBY_VERSION
|
136
|
+
platform_info['Ruby.Oboe.Version'] = ::Oboe::Version::STRING
|
137
|
+
platform_info['RubyHeroku.Oboe.Version'] = ::OboeHeroku::Version::STRING if defined?(::OboeHeroku)
|
138
|
+
|
139
|
+
# Report the framework in use
|
140
|
+
if defined?(::RailsLts)
|
141
|
+
platform_info['Ruby.RailsLts.Version'] = "RailsLts-#{::RailsLts::VERSION}"
|
142
|
+
elsif defined?(::Rails)
|
143
|
+
platform_info['Ruby.Rails.Version'] = "Rails-#{::Rails.version}"
|
144
|
+
end
|
145
|
+
platform_info['Ruby.Grape.Version'] = "Grape-#{::Grape::VERSION}" if defined?(::Grape)
|
146
|
+
platform_info['Ruby.Cramp.Version'] = "Cramp-#{::Cramp::VERSION}" if defined?(::Cramp)
|
147
|
+
|
148
|
+
if defined?(::Padrino)
|
149
|
+
platform_info['Ruby.Padrino.Version'] = "Padrino-#{::Padrino::VERSION}"
|
150
|
+
elsif defined?(::Sinatra)
|
151
|
+
platform_info['Ruby.Sinatra.Version'] = "Sinatra-#{::Sinatra::VERSION}"
|
152
|
+
end
|
153
|
+
|
154
|
+
# Report the instrumented libraries
|
155
|
+
platform_info['Ruby.Cassandra.Version'] = "Cassandra-#{::Cassandra.VERSION}" if defined?(::Cassandra)
|
156
|
+
platform_info['Ruby.Dalli.Version'] = "Dalli-#{::Dalli::VERSION}" if defined?(::Dalli)
|
157
|
+
platform_info['Ruby.MemCache.Version'] = "MemCache-#{::MemCache::VERSION}" if defined?(::MemCache)
|
158
|
+
platform_info['Ruby.Moped.Version'] = "Moped-#{::Moped::VERSION}" if defined?(::Moped)
|
159
|
+
platform_info['Ruby.Redis.Version'] = "Redis-#{::Redis::VERSION}" if defined?(::Redis)
|
160
|
+
platform_info['Ruby.Resque.Version'] = "Resque-#{::Resque::VERSION}" if defined?(::Resque)
|
161
|
+
|
162
|
+
# Special case since the Mongo 1.x driver doesn't embed the version number in the gem directly
|
163
|
+
if ::Gem.loaded_specs.key?('mongo')
|
164
|
+
platform_info['Ruby.Mongo.Version'] = "Mongo-#{::Gem.loaded_specs['mongo'].version}"
|
165
|
+
end
|
166
|
+
|
167
|
+
# Report the server in use (if possible)
|
168
|
+
if defined?(::Unicorn)
|
169
|
+
platform_info['Ruby.AppContainer.Version'] = "Unicorn-#{::Unicorn::Const::UNICORN_VERSION}"
|
170
|
+
elsif defined?(::Puma)
|
171
|
+
platform_info['Ruby.AppContainer.Version'] = "Puma-#{::Puma::Const::PUMA_VERSION} (#{::Puma::Const::CODE_NAME})"
|
172
|
+
elsif defined?(::PhusionPassenger)
|
173
|
+
platform_info['Ruby.AppContainer.Version'] = "#{::PhusionPassenger::PACKAGE_NAME}-#{::PhusionPassenger::VERSION_STRING}"
|
174
|
+
elsif defined?(::Thin)
|
175
|
+
platform_info['Ruby.AppContainer.Version'] = "Thin-#{::Thin::VERSION::STRING} (#{::Thin::VERSION::CODENAME})"
|
176
|
+
elsif defined?(::Mongrel)
|
177
|
+
platform_info['Ruby.AppContainer.Version'] = "Mongrel-#{::Mongrel::Const::MONGREL_VERSION}"
|
178
|
+
elsif defined?(::Mongrel2)
|
179
|
+
platform_info['Ruby.AppContainer.Version'] = "Mongrel2-#{::Mongrel2::VERSION}"
|
180
|
+
elsif defined?(::Trinidad)
|
181
|
+
platform_info['Ruby.AppContainer.Version'] = "Trinidad-#{::Trinidad::VERSION}"
|
182
|
+
elsif defined?(::WEBrick)
|
183
|
+
platform_info['Ruby.AppContainer.Version'] = "WEBrick-#{::WEBrick::VERSION}"
|
184
|
+
else
|
185
|
+
platform_info['Ruby.AppContainer.Version'] = File.basename($PROGRAM_NAME)
|
186
|
+
end
|
187
|
+
|
188
|
+
rescue StandardError, ScriptError => e
|
189
|
+
# Also rescue ScriptError (aka SyntaxError) in case one of the expected
|
190
|
+
# version defines don't exist
|
191
|
+
|
192
|
+
platform_info['Error'] = "Error in build_report: #{e.message}"
|
193
|
+
|
194
|
+
Oboe.logger.debug "Error in build_report: #{e.message}"
|
195
|
+
Oboe.logger.debug e.backtrace
|
196
|
+
end
|
197
|
+
platform_info
|
198
|
+
end
|
126
199
|
end
|
127
200
|
end
|
128
201
|
end
|
129
|
-
|
data/lib/oboe/version.rb
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# The current version of the gem. Used mainly by
|
7
|
+
# oboe.gemspec during gem build process
|
5
8
|
module Version
|
6
9
|
MAJOR = 2
|
7
10
|
MINOR = 7
|
8
|
-
PATCH =
|
9
|
-
BUILD =
|
11
|
+
PATCH = 2
|
12
|
+
BUILD = "fuchs1"
|
10
13
|
|
11
14
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
12
15
|
end
|
data/lib/oboe/xtrace.rb
CHANGED
@@ -2,31 +2,31 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# Methods to act on, manipulate or investigate an X-Trace
|
7
|
+
# value
|
5
8
|
module XTrace
|
6
9
|
class << self
|
7
|
-
|
8
10
|
##
|
9
11
|
# Oboe::XTrace.valid?
|
10
12
|
#
|
11
13
|
# Perform basic validation on a potential X-Trace ID
|
12
14
|
#
|
13
15
|
def valid?(xtrace)
|
14
|
-
|
15
|
-
|
16
|
-
return false unless xtrace
|
16
|
+
# Shouldn't be nil
|
17
|
+
return false unless xtrace
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
# The X-Trace ID shouldn't be an initialized empty ID
|
20
|
+
return false if (xtrace =~ /^1b0000000/i) == 0
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
# Valid X-Trace IDs have a length of 58 bytes and start with '1b'
|
23
|
+
return false unless xtrace.length == 58 && (xtrace =~ /^1b/i) == 0
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
25
|
+
true
|
26
|
+
rescue StandardError => e
|
27
|
+
Oboe.logger.debug e.message
|
28
|
+
Oboe.logger.debug e.backtrace
|
29
|
+
false
|
30
30
|
end
|
31
31
|
|
32
32
|
##
|
@@ -35,18 +35,14 @@ module Oboe
|
|
35
35
|
# Extract and return the task_id portion of an X-Trace ID
|
36
36
|
#
|
37
37
|
def task_id(xtrace)
|
38
|
-
|
39
|
-
return nil unless Oboe::XTrace.valid?(xtrace)
|
38
|
+
return nil unless Oboe::XTrace.valid?(xtrace)
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
40
|
+
xtrace[2..41]
|
41
|
+
rescue StandardError => e
|
42
|
+
Oboe.logger.debug e.message
|
43
|
+
Oboe.logger.debug e.backtrace
|
44
|
+
return nil
|
47
45
|
end
|
48
|
-
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|
52
|
-
|
data/lib/oboe_metal.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
+
# Disable docs and Camelcase warns since we're implementing
|
5
|
+
# an interface here. See OboeBase for details.
|
6
|
+
# rubocop:disable Style/Documentation, Style/MethodName
|
4
7
|
module Oboe
|
5
8
|
extend OboeBase
|
6
9
|
include Oboe_metal
|
@@ -13,21 +16,21 @@ module Oboe
|
|
13
16
|
return unless Oboe.loaded
|
14
17
|
|
15
18
|
begin
|
16
|
-
Oboe_metal::Context.init
|
19
|
+
Oboe_metal::Context.init
|
17
20
|
|
18
|
-
if ENV.
|
19
|
-
Oboe.reporter = Oboe::FileReporter.new(
|
21
|
+
if ENV.key?('OBOE_GEM_TEST')
|
22
|
+
Oboe.reporter = Oboe::FileReporter.new('/tmp/trace_output.bson')
|
20
23
|
else
|
21
24
|
Oboe.reporter = Oboe::UdpReporter.new(Oboe::Config[:reporter_host], Oboe::Config[:reporter_port])
|
22
25
|
end
|
23
26
|
|
24
27
|
# Only report __Init from here if we are not instrumenting a framework.
|
25
28
|
# Otherwise, frameworks will handle reporting __Init after full initialization
|
26
|
-
unless defined?(::Rails)
|
29
|
+
unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
|
27
30
|
Oboe::API.report_init
|
28
31
|
end
|
29
32
|
|
30
|
-
rescue
|
33
|
+
rescue => e
|
31
34
|
$stderr.puts e.message
|
32
35
|
raise
|
33
36
|
end
|
@@ -52,7 +55,7 @@ module Oboe
|
|
52
55
|
# Retrieves all traces written to the trace file
|
53
56
|
#
|
54
57
|
def self.get_all_traces
|
55
|
-
io = File.open($trace_file,
|
58
|
+
io = File.open($trace_file, 'r')
|
56
59
|
contents = io.readlines(nil)
|
57
60
|
|
58
61
|
return contents if contents.empty?
|
@@ -75,7 +78,7 @@ module Oboe
|
|
75
78
|
|
76
79
|
class Event
|
77
80
|
def self.metadataString(evt)
|
78
|
-
evt.metadataString
|
81
|
+
evt.metadataString
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
@@ -92,7 +95,7 @@ module Oboe
|
|
92
95
|
rv = Oboe::Context.sampleRequest(layer, xtrace, tv_meta)
|
93
96
|
|
94
97
|
# For older liboboe that returns true/false, just return that.
|
95
|
-
return rv if [TrueClass, FalseClass].include?(rv.class)
|
98
|
+
return rv if [TrueClass, FalseClass].include?(rv.class) || (rv == 0)
|
96
99
|
|
97
100
|
# liboboe version > 1.3.1 returning a bit masked integer with SampleRate and
|
98
101
|
# source embedded
|
@@ -126,13 +129,13 @@ module Oboe
|
|
126
129
|
end
|
127
130
|
|
128
131
|
def set_sample_rate(rate)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
132
|
+
return unless Oboe.loaded
|
133
|
+
|
134
|
+
# Update liboboe with the new SampleRate value
|
135
|
+
Oboe::Context.setDefaultSampleRate(rate.to_i)
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
139
|
+
# rubocop:enable Style/Documentation
|
136
140
|
|
137
141
|
Oboe.loaded = true
|
138
|
-
|
@@ -52,6 +52,7 @@ if defined?(Oboe::Config)
|
|
52
52
|
# Oboe::Config[:action_view][:enabled] = true
|
53
53
|
# Oboe::Config[:cassandra][:enabled] = true
|
54
54
|
# Oboe::Config[:dalli][:enabled] = true
|
55
|
+
# Oboe::Config[:faraday][:enabled] = true
|
55
56
|
# Oboe::Config[:memcache][:enabled] = true
|
56
57
|
# Oboe::Config[:memcached][:enabled] = true
|
57
58
|
# Oboe::Config[:mongo][:enabled] = true
|
@@ -74,6 +75,7 @@ if defined?(Oboe::Config)
|
|
74
75
|
# Oboe::Config[:action_view][:collect_backtraces] = true
|
75
76
|
# Oboe::Config[:cassandra][:collect_backtraces] = true
|
76
77
|
# Oboe::Config[:dalli][:collect_backtraces] = false
|
78
|
+
# Oboe::Config[:faraday][:collect_backtraces] = false
|
77
79
|
# Oboe::Config[:memcache][:collect_backtraces] = false
|
78
80
|
# Oboe::Config[:memcached][:collect_backtraces] = false
|
79
81
|
# Oboe::Config[:mongo][:collect_backtraces] = true
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe Oboe::Inst::FaradayConnection do
|
4
|
+
before do
|
5
|
+
clear_all_traces
|
6
|
+
@collect_backtraces = Oboe::Config[:faraday][:collect_backtraces]
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Oboe::Config[:faraday][:collect_backtraces] = @collect_backtraces
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'Faraday should be defined and ready' do
|
14
|
+
defined?(::Faraday).wont_match nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Faraday should have oboe methods defined' do
|
18
|
+
[ :run_request_with_oboe ].each do |m|
|
19
|
+
::Faraday::Connection.method_defined?(m).must_equal true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should trace a Faraday request to an instr'd app" do
|
24
|
+
Oboe::API.start_trace('faraday_test') do
|
25
|
+
conn = Faraday.new(:url => 'http://www.appneta.com') do |faraday|
|
26
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
27
|
+
end
|
28
|
+
response = conn.get '/?q=ruby_test_suite'
|
29
|
+
end
|
30
|
+
|
31
|
+
traces = get_all_traces
|
32
|
+
traces.count.must_equal 7
|
33
|
+
|
34
|
+
validate_outer_layers(traces, 'faraday_test')
|
35
|
+
|
36
|
+
traces[1]['Layer'].must_equal 'faraday'
|
37
|
+
traces[1].key?('Backtrace').must_equal Oboe::Config[:faraday][:collect_backtraces]
|
38
|
+
|
39
|
+
traces[3]['Layer'].must_equal 'net-http'
|
40
|
+
traces[3]['IsService'].must_equal '1'
|
41
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
42
|
+
traces[3]['RemoteHost'].must_equal 'www.appneta.com'
|
43
|
+
traces[3]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
44
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
45
|
+
traces[3]['HTTPStatus'].must_equal '200'
|
46
|
+
|
47
|
+
traces[4]['Layer'].must_equal 'net-http'
|
48
|
+
traces[4]['Label'].must_equal 'exit'
|
49
|
+
|
50
|
+
traces[5]['Layer'].must_equal 'faraday'
|
51
|
+
traces[5]['Label'].must_equal 'exit'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should trace a Faraday request' do
|
55
|
+
Oboe::API.start_trace('faraday_test') do
|
56
|
+
conn = Faraday.new(:url => 'http://www.google.com') do |faraday|
|
57
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
58
|
+
end
|
59
|
+
response = conn.get '/?q=ruby_test_suite'
|
60
|
+
end
|
61
|
+
|
62
|
+
traces = get_all_traces
|
63
|
+
traces.count.must_equal 7
|
64
|
+
|
65
|
+
validate_outer_layers(traces, 'faraday_test')
|
66
|
+
|
67
|
+
traces[1]['Layer'].must_equal 'faraday'
|
68
|
+
traces[1].key?('Backtrace').must_equal Oboe::Config[:faraday][:collect_backtraces]
|
69
|
+
|
70
|
+
traces[3]['Layer'].must_equal 'net-http'
|
71
|
+
traces[3]['IsService'].must_equal '1'
|
72
|
+
traces[3]['RemoteProtocol'].must_equal 'HTTP'
|
73
|
+
traces[3]['RemoteHost'].must_equal 'www.google.com'
|
74
|
+
traces[3]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
75
|
+
traces[3]['HTTPMethod'].must_equal 'GET'
|
76
|
+
traces[3]['HTTPStatus'].must_equal '200'
|
77
|
+
|
78
|
+
traces[4]['Layer'].must_equal 'net-http'
|
79
|
+
traces[4]['Label'].must_equal 'exit'
|
80
|
+
|
81
|
+
traces[5]['Layer'].must_equal 'faraday'
|
82
|
+
traces[5]['Label'].must_equal 'exit'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should trace a Faraday with an alternate adapter' do
|
86
|
+
Oboe::API.start_trace('faraday_test') do
|
87
|
+
conn = Faraday.new(:url => 'http://www.google.com') do |faraday|
|
88
|
+
faraday.adapter :excon
|
89
|
+
end
|
90
|
+
response = conn.get '/?q=ruby_test_suite'
|
91
|
+
end
|
92
|
+
|
93
|
+
traces = get_all_traces
|
94
|
+
traces.count.must_equal 5
|
95
|
+
|
96
|
+
validate_outer_layers(traces, 'faraday_test')
|
97
|
+
|
98
|
+
traces[1]['Layer'].must_equal 'faraday'
|
99
|
+
traces[1].key?('Backtrace').must_equal Oboe::Config[:faraday][:collect_backtraces]
|
100
|
+
|
101
|
+
traces[1]['IsService'].must_equal '1'
|
102
|
+
traces[1]['RemoteProtocol'].must_equal 'HTTP'
|
103
|
+
traces[1]['RemoteHost'].must_equal 'www.google.com'
|
104
|
+
traces[1]['ServiceArg'].must_equal '/?q=ruby_test_suite'
|
105
|
+
traces[1]['HTTPMethod'].downcase.must_equal 'get'
|
106
|
+
|
107
|
+
traces[2]['Layer'].must_equal 'faraday'
|
108
|
+
traces[2]['Label'].must_equal 'info'
|
109
|
+
traces[2]['HTTPStatus'].must_equal '200'
|
110
|
+
|
111
|
+
traces[3]['Layer'].must_equal 'faraday'
|
112
|
+
traces[3]['Label'].must_equal 'exit'
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should obey :collect_backtraces setting when true' do
|
116
|
+
Oboe::Config[:faraday][:collect_backtraces] = true
|
117
|
+
|
118
|
+
Oboe::API.start_trace('faraday_test') do
|
119
|
+
conn = Faraday.new(:url => 'http://www.google.com') do |faraday|
|
120
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
121
|
+
end
|
122
|
+
response = conn.get '/?q=ruby_test_suite'
|
123
|
+
end
|
124
|
+
|
125
|
+
traces = get_all_traces
|
126
|
+
layer_has_key(traces, 'faraday', 'Backtrace')
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should obey :collect_backtraces setting when false' do
|
130
|
+
Oboe::Config[:faraday][:collect_backtraces] = false
|
131
|
+
|
132
|
+
Oboe::API.start_trace('faraday_test') do
|
133
|
+
conn = Faraday.new(:url => 'http://www.google.com') do |faraday|
|
134
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
135
|
+
end
|
136
|
+
response = conn.get '/?q=ruby_test_suite'
|
137
|
+
end
|
138
|
+
|
139
|
+
traces = get_all_traces
|
140
|
+
layer_doesnt_have_key(traces, 'faraday', 'Backtrace')
|
141
|
+
end
|
142
|
+
end
|