oboe 2.7.5.1-java → 2.7.6.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce92819a96ee793cbe17199fc0fbfe12c03b8548
4
- data.tar.gz: 22a7a87fa39eda4a1e2c52854fb71508f923dc0e
3
+ metadata.gz: 04dd4cedfddf93bfec87da8c4cc8ce567774aa8e
4
+ data.tar.gz: fb4f5faf217e9182c39d5288ba011369f0f8775f
5
5
  SHA512:
6
- metadata.gz: c184bb5ebe38c0ee89b6ebe09f99a371a576bd61f23354fddf99c1eadf7026696deadefe14651628af9aa87b0f1594df00565e9954b4ec1d9ba252b51f628198
7
- data.tar.gz: 0f27e2ae0c3077d80560e47fd2111a464ecdc72dc8a4ece0ecd3d845cbac46cfb1e8b91589f8a1cdac9887ea8de1e36b07acba4f6027e2139ade9f26af002ed9
6
+ metadata.gz: 2dcefcf8a35fe0e4bec770b9eec4a54cb00def48628c3fada333eaa28d0d38b3f3f0ef38a00bda3f60ac83e488736c70c6cf541dc203b9d9145643202d6bf1be
7
+ data.tar.gz: e5d5c5998ba93f4bb21b6d7b44294291ae486edaa6959071e972f1a17cfc2bef3c4f9fdfa873da946116a2829921becd71b687d4f1a79380b947bdabd202a3ce
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ group :development do
11
11
  gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
12
12
  gem 'debugger', :platform => :mri_19
13
13
  gem 'byebug', :platforms => [ :mri_20, :mri_21 ]
14
- gem 'perftools.rb', :platforms => [ :mri_20, :mri_21 ], :require => 'perftools'
14
+ # gem 'perftools.rb', :platforms => [ :mri_20, :mri_21 ], :require => 'perftools'
15
15
  if RUBY_VERSION > '1.8.7'
16
16
  gem 'pry'
17
17
  gem 'pry-byebug', :platforms => [ :mri_20, :mri_21 ]
@@ -32,7 +32,7 @@ gem 'excon'
32
32
  gem 'typhoeus'
33
33
 
34
34
  if RUBY_VERSION >= '1.9'
35
- gem 'moped'
35
+ gem 'moped', '1.3.2'
36
36
  gem 'eventmachine'
37
37
  gem 'em-synchrony'
38
38
  gem 'em-http-request'
@@ -12,7 +12,7 @@ module Oboe_metal
12
12
  class Context
13
13
  class << self
14
14
  def toString
15
- md = getMetadata.toHexString
15
+ getMetadata.toHexString
16
16
  end
17
17
 
18
18
  def fromString(xtrace)
@@ -71,9 +71,9 @@ module Oboe_metal
71
71
  Oboe::Config.tracing_mode = 'never'
72
72
  end
73
73
 
74
- Oboe.sample_rate = cfg.sampleRate
74
+ Oboe.sample_rate = cfg.getSampleRate
75
75
  Oboe::Config.sample_rate = cfg.sampleRate
76
- Oboe::Config.sample_source = cfg.sampleRateSource.a
76
+ Oboe::Config.sample_source = cfg.sampleRateSourceValue
77
77
  rescue => e
78
78
  Oboe.logger.debug "[oboe/debug] Couldn't retrieve/acces joboe sampleRateCfg"
79
79
  Oboe.logger.debug "[oboe/debug] #{e.message}"
@@ -18,7 +18,19 @@ module Oboe
18
18
  return unless Oboe.loaded
19
19
 
20
20
  platform_info = Oboe::Util.build_init_report
21
+
22
+ # If already tracing, save and clear the context. Restore it after
23
+ # the __Init is sent
24
+ context = nil
25
+
26
+ if Oboe.tracing?
27
+ context = Oboe::Context.toString
28
+ Oboe::Context.clear
29
+ end
30
+
21
31
  start_trace(layer, nil, platform_info.merge('Force' => true)) {}
32
+
33
+ Oboe::Context.fromString(context) if context
22
34
  end
23
35
 
24
36
  ##
@@ -63,12 +63,13 @@ module Oboe
63
63
  #
64
64
  # Returns nothing.
65
65
  def log_start(layer, xtrace, opts = {})
66
- return if !Oboe.loaded || Oboe.never? ||
66
+ return if !Oboe.loaded || Oboe.never? ||
67
67
  (opts.key?(:URL) && ::Oboe::Util.static_asset?(opts[:URL]))
68
68
 
69
- Oboe::Context.fromString(xtrace) if xtrace && !xtrace.to_s.empty?
69
+ Oboe::Context.fromString(xtrace) if Oboe.pickup_context?(xtrace)
70
70
 
71
71
  if Oboe.tracing?
72
+ Oboe.is_continued_trace = true
72
73
  log_entry(layer, opts)
73
74
  elsif opts.key?('Force') || Oboe.sample?(opts.merge(:layer => layer, :xtrace => xtrace))
74
75
  log_event(layer, 'entry', Oboe::Context.startTrace, opts)
@@ -84,7 +85,7 @@ module Oboe
84
85
  if Oboe.loaded
85
86
  log_event(layer, 'exit', Oboe::Context.createEvent, opts)
86
87
  xtrace = Oboe::Context.toString
87
- Oboe::Context.clear
88
+ Oboe::Context.clear unless Oboe.has_incoming_context?
88
89
  xtrace
89
90
  end
90
91
  end
@@ -35,14 +35,79 @@ module OboeBase
35
35
  attr_accessor :sample_rate
36
36
  thread_local :layer_op
37
37
 
38
- def self.included(cls)
39
- cls.loaded = true
40
- end
38
+ # The following accessors indicate the incoming tracing state received
39
+ # by the rack layer. These are primarily used to identify state
40
+ # between the Ruby and JOboe instrumentation under JRuby.
41
+ #
42
+ # This is because that even though there may be an incoming
43
+ # X-Trace request header, tracing may have already been started
44
+ # by Joboe. Such a scenario occurs when the application is being
45
+ # hosted by a Java container (such as Tomcat or Glassfish) and
46
+ # JOboe has already initiated tracing. In this case, we shouldn't
47
+ # pickup the X-Trace context in the X-Trace header and we shouldn't
48
+ # set the outgoing response X-Trace header or clear context.
49
+ # Yeah I know. Yuck.
50
+
51
+ # Occurs only on Jruby. Indicates that Joboe (the java instrumentation)
52
+ # has already started tracing before it hit the JRuby instrumentation.
53
+ thread_local :has_incoming_context
54
+
55
+ # Indicates the existence of a valid X-Trace request header
56
+ thread_local :has_xtrace_header
57
+
58
+ # This indicates that this trace was continued from
59
+ # an incoming X-Trace request header or in the case
60
+ # of JRuby, a trace already started by JOboe.
61
+ thread_local :is_continued_trace
41
62
 
63
+ ##
64
+ # extended
65
+ #
66
+ # Invoked when this module is extended.
67
+ # e.g. extend OboeBase
68
+ #
42
69
  def self.extended(cls)
43
70
  cls.loaded = true
71
+
72
+ # This gives us pretty accessors with questions marks at the end
73
+ # e.g. is_continued_trace --> is_continued_trace?
74
+ Oboe.methods.select{ |m| m =~ /^is_|^has_/ }.each do |c|
75
+ unless c =~ /\?$|=$/
76
+ # Oboe.logger.debug "aliasing #{c}? to #{c}"
77
+ alias_method "#{c}?", c
78
+ end
79
+ end
80
+ end
81
+
82
+ ##
83
+ # pickup_context
84
+ #
85
+ # Determines whether we should pickup context
86
+ # from an incoming X-Trace request header. The answer
87
+ # is generally yes but there are cases in JRuby under
88
+ # Tomcat (or Glassfish etc.) where tracing may have
89
+ # been already started by the Java instrumentation (Joboe)
90
+ # in which case we don't want to do this.
91
+ #
92
+ def pickup_context?(xtrace)
93
+ return false unless Oboe::XTrace.valid?(xtrace)
94
+
95
+ if defined?(JRUBY_VERSION) && Oboe.tracing?
96
+ return false
97
+ else
98
+ return true
99
+ end
44
100
  end
45
101
 
102
+ ##
103
+ # tracing_layer_op?
104
+ #
105
+ # Queries the thread local variable about the current
106
+ # operation being traced. This is used in cases of recursive
107
+ # operation tracing or one instrumented operation calling another.
108
+ #
109
+ # In such cases, we only want to trace the outermost operation.
110
+ #
46
111
  def tracing_layer_op?(operation)
47
112
  if operation.is_a?(Array)
48
113
  return operation.include?(Oboe.layer_op)
@@ -7,7 +7,7 @@ require 'oboe/frameworks/rails/inst/connection_adapters/mysql2'
7
7
  require 'oboe/frameworks/rails/inst/connection_adapters/postgresql'
8
8
  require 'oboe/frameworks/rails/inst/connection_adapters/oracle'
9
9
 
10
- if Oboe::Config[:active_record][:enabled]
10
+ if Oboe::Config[:active_record][:enabled] && !defined?(JRUBY_VERSION)
11
11
  begin
12
12
  adapter = ActiveRecord::Base.connection.adapter_name.downcase
13
13
 
@@ -11,6 +11,9 @@ if Oboe::Config[:nethttp][:enabled]
11
11
  return request_without_oboe(*args, &block)
12
12
  end
13
13
 
14
+ # If we're not tracing, just do a fast return
15
+ return request_without_oboe(*args, &block) unless Oboe.tracing?
16
+
14
17
  # Avoid cross host tracing for blacklisted domains
15
18
  blacklisted = Oboe::API.blacklisted?(addr_port)
16
19
 
@@ -450,10 +450,11 @@ if defined?(::Moped) && Oboe::Config[:moped][:enabled]
450
450
  end
451
451
  end
452
452
 
453
- def aggregate_with_oboe(pipeline)
453
+ def aggregate_with_oboe(*pipeline)
454
454
  return aggregate_without_oboe(pipeline) unless Oboe.tracing?
455
455
 
456
456
  report_kvs = extract_trace_details(:aggregate)
457
+ report_kvs[:Query] = pipeline
457
458
 
458
459
  Oboe::API.trace('mongo', report_kvs) do
459
460
  aggregate_without_oboe(pipeline)
@@ -52,14 +52,24 @@ module Oboe
52
52
 
53
53
  if Oboe.always?
54
54
  # Only report these KVs under tracing_mode 'always' (never for 'through')
55
+ # These KVs need to be in the entry event for server side.
55
56
  report_kvs[:SampleRate] = Oboe.sample_rate
56
57
  report_kvs[:SampleSource] = Oboe.sample_source
57
58
  end
58
59
 
60
+ # Under JRuby, JOboe may have already started a trace. Make note of this
61
+ # if so and don't clear context on log_end (see oboe/api/logging.rb)
62
+ Oboe.has_incoming_context = Oboe.tracing?
63
+
64
+ # Check for and validate X-Trace request header to pick up tracing context
59
65
  xtrace = env.is_a?(Hash) ? env['HTTP_X_TRACE'] : nil
66
+ xtrace_header = xtrace if xtrace && Oboe::XTrace.valid?(xtrace)
67
+ Oboe.has_xtrace_header = xtrace_header
60
68
 
61
- result, xtrace = Oboe::API.start_trace('rack', xtrace, report_kvs) do
69
+ Oboe.is_continued_trace = Oboe.has_incoming_context or Oboe.has_xtrace_header
62
70
 
71
+ # The actual block of work to instrument
72
+ result, xtrace = Oboe::API.start_trace('rack', xtrace_header, report_kvs) do
63
73
  status, headers, response = @app.call(env)
64
74
 
65
75
  if Oboe.tracing?
@@ -73,8 +83,13 @@ module Oboe
73
83
  xtrace = e.instance_variable_get(:@xtrace)
74
84
  raise
75
85
  ensure
76
- result[1]['X-Trace'] = xtrace if result && Oboe::XTrace.valid?(xtrace)
86
+ if result && Oboe::XTrace.valid?(xtrace)
87
+ unless defined?(JRUBY_VERSION) && Oboe.is_continued_trace?
88
+ result[1]['X-Trace'] = xtrace
89
+ end
90
+ end
77
91
  return result
78
92
  end
79
93
  end
80
94
  end
95
+
@@ -8,8 +8,8 @@ module Oboe
8
8
  module Version
9
9
  MAJOR = 2
10
10
  MINOR = 7
11
- PATCH = 5
12
- BUILD = 1
11
+ PATCH = 6
12
+ BUILD = 2
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
15
15
  end
@@ -22,10 +22,11 @@ describe Oboe::Inst::FaradayConnection do
22
22
 
23
23
  it "should trace a Faraday request to an instr'd app" do
24
24
  Oboe::API.start_trace('faraday_test') do
25
- conn = Faraday.new(:url => 'http://www.appneta.com') do |faraday|
25
+ conn = Faraday.new(:url => 'http://www.gameface.in') do |faraday|
26
26
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
27
27
  end
28
- response = conn.get '/?q=ruby_test_suite'
28
+ response = conn.get '/games?q=1'
29
+ response.headers["x-trace"].wont_match nil
29
30
  end
30
31
 
31
32
  traces = get_all_traces
@@ -39,8 +40,8 @@ describe Oboe::Inst::FaradayConnection do
39
40
  traces[3]['Layer'].must_equal 'net-http'
40
41
  traces[3]['IsService'].must_equal '1'
41
42
  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'
43
+ traces[3]['RemoteHost'].must_equal 'www.gameface.in'
44
+ traces[3]['ServiceArg'].must_equal '/games?q=1'
44
45
  traces[3]['HTTPMethod'].must_equal 'GET'
45
46
  traces[3]['HTTPStatus'].must_equal '200'
46
47
 
@@ -118,10 +119,10 @@ describe Oboe::Inst::FaradayConnection do
118
119
 
119
120
  it 'should trace a Faraday with an alternate adapter' do
120
121
  Oboe::API.start_trace('faraday_test') do
121
- conn = Faraday.new(:url => 'http://www.google.com') do |faraday|
122
+ conn = Faraday.new(:url => 'http://www.curlmyip.com') do |faraday|
122
123
  faraday.adapter :excon
123
124
  end
124
- response = conn.get '/?q=ruby_test_suite'
125
+ response = conn.get '/?q=1'
125
126
  end
126
127
 
127
128
  traces = get_all_traces
@@ -134,8 +135,8 @@ describe Oboe::Inst::FaradayConnection do
134
135
 
135
136
  traces[2]['IsService'].must_equal '1'
136
137
  traces[2]['RemoteProtocol'].must_equal 'HTTP'
137
- traces[2]['RemoteHost'].must_equal 'www.google.com'
138
- traces[2]['ServiceArg'].must_equal '/?q=ruby_test_suite'
138
+ traces[2]['RemoteHost'].must_equal 'www.curlmyip.com'
139
+ traces[2]['ServiceArg'].must_equal '/?q=1'
139
140
  traces[2]['HTTPMethod'].downcase.must_equal 'get'
140
141
 
141
142
  traces[2]['Layer'].must_equal 'faraday'
@@ -23,10 +23,12 @@ describe Oboe::Inst do
23
23
 
24
24
  it "should trace a Net::HTTP request to an instr'd app" do
25
25
  Oboe::API.start_trace('net-http_test', '', {}) do
26
- uri = URI('http://www.appneta.com')
26
+ uri = URI('http://www.gameface.in/games?q=1')
27
27
  http = Net::HTTP.new(uri.host, uri.port)
28
- http.use_ssl = false
29
- http.get('/?q=ruby_test_suite').read_body
28
+ request = Net::HTTP::Get.new(uri.request_uri)
29
+ response = http.request(request)
30
+ # The HTTP response should have an X-Trace header inside of it
31
+ response["x-trace"].wont_match nil
30
32
  end
31
33
 
32
34
  traces = get_all_traces
@@ -37,8 +39,8 @@ describe Oboe::Inst do
37
39
  traces[1]['Layer'].must_equal 'net-http'
38
40
  traces[2]['IsService'].must_equal "1"
39
41
  traces[2]['RemoteProtocol'].must_equal "HTTP"
40
- traces[2]['RemoteHost'].must_equal "www.appneta.com"
41
- traces[2]['ServiceArg'].must_equal "/?q=ruby_test_suite"
42
+ traces[2]['RemoteHost'].must_equal "www.gameface.in"
43
+ traces[2]['ServiceArg'].must_equal "/games?q=1"
42
44
  traces[2]['HTTPMethod'].must_equal "GET"
43
45
  traces[2]['HTTPStatus'].must_equal "200"
44
46
  traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
@@ -46,10 +48,9 @@ describe Oboe::Inst do
46
48
 
47
49
  it "should trace a Net::HTTP request" do
48
50
  Oboe::API.start_trace('net-http_test', '', {}) do
49
- uri = URI('https://www.google.com')
51
+ uri = URI('http://www.curlmyip.com')
50
52
  http = Net::HTTP.new(uri.host, uri.port)
51
- http.use_ssl = true
52
- http.get('/?q=ruby_test_suite').read_body
53
+ http.get('/?q=1').read_body
53
54
  end
54
55
 
55
56
  traces = get_all_traces
@@ -59,9 +60,9 @@ describe Oboe::Inst do
59
60
 
60
61
  traces[1]['Layer'].must_equal 'net-http'
61
62
  traces[2]['IsService'].must_equal "1"
62
- traces[2]['RemoteProtocol'].must_equal "HTTPS"
63
- traces[2]['RemoteHost'].must_equal "www.google.com"
64
- traces[2]['ServiceArg'].must_equal "/?q=ruby_test_suite"
63
+ traces[2]['RemoteProtocol'].must_equal "HTTP"
64
+ traces[2]['RemoteHost'].must_equal "www.curlmyip.com"
65
+ traces[2]['ServiceArg'].must_equal "/?q=1"
65
66
  traces[2]['HTTPMethod'].must_equal "GET"
66
67
  traces[2]['HTTPStatus'].must_equal "200"
67
68
  traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
@@ -4,7 +4,7 @@ require 'memcache'
4
4
  describe Oboe::API::Memcache do
5
5
  before do
6
6
  clear_all_traces
7
- @mc = ::MemCache.new('localhost')
7
+ @mc = ::MemCache.new('127.0.0.1')
8
8
 
9
9
  # These are standard entry/exit KVs that are passed up with all mongo operations
10
10
  @entry_kvs = {
@@ -77,7 +77,7 @@ describe Oboe::API::Memcache do
77
77
 
78
78
  validate_event_keys(traces[2], @info_kvs)
79
79
  traces[2]['KVKey'].must_equal "msg"
80
- traces[2]['RemoteHost'].must_equal "localhost"
80
+ traces[2]['RemoteHost'].must_equal "127.0.0.1"
81
81
  traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
82
82
 
83
83
  traces[3].has_key?('KVHit').must_equal true
@@ -7,7 +7,7 @@ if RUBY_VERSION < '2.0' and not defined?(JRUBY_VERSION)
7
7
 
8
8
  before do
9
9
  clear_all_traces
10
- @mc = ::Memcached::Rails.new(:servers => ['localhost'])
10
+ @mc = ::Memcached::Rails.new(:servers => ['127.0.0.1'])
11
11
 
12
12
  # These are standard entry/exit KVs that are passed up with all mongo operations
13
13
  @entry_kvs = {
@@ -449,6 +449,27 @@ if RUBY_VERSION >= '1.9.3'
449
449
  validate_event_keys(traces[4], @exit_kvs)
450
450
  end
451
451
 
452
+ it 'should trace aggregate' do
453
+ Oboe::API.start_trace('moped_test', '', {}) do
454
+ @users.aggregate(
455
+ {'$match' => {:name => "Mary"}},
456
+ {'$group' => {"_id" => "$name"}}
457
+ )
458
+ end
459
+
460
+ traces = get_all_traces
461
+
462
+ traces.count.must_equal 4
463
+ validate_outer_layers(traces, 'moped_test')
464
+
465
+ validate_event_keys(traces[1], @entry_kvs)
466
+ traces[1]['QueryOp'].must_equal "aggregate"
467
+ traces[1]['Query'].must_equal "[{\"$match\"=>{:name=>\"Mary\"}}, {\"$group\"=>{\"_id\"=>\"$name\"}}]"
468
+ traces[1]['Collection'].must_equal "users"
469
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
470
+ validate_event_keys(traces[2], @exit_kvs)
471
+ end
472
+
452
473
  it "should obey :collect_backtraces setting when true" do
453
474
  Oboe::Config[:moped][:collect_backtraces] = true
454
475
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oboe
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.5.1
4
+ version: 2.7.6.2
5
5
  platform: java
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-20 00:00:00.000000000 Z
12
+ date: 2014-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json