oboe 2.6.8 → 2.7.0.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +15 -7
- data/README.md +7 -20
- data/Rakefile +58 -43
- data/ext/oboe_metal/extconf.rb +1 -6
- data/lib/base.rb +9 -17
- data/lib/joboe_metal.rb +102 -22
- data/lib/oboe.rb +2 -2
- data/lib/oboe/api/logging.rb +3 -3
- data/lib/oboe/api/tracing.rb +2 -2
- data/lib/oboe/frameworks/padrino/templates.rb +1 -1
- data/lib/oboe/frameworks/sinatra/templates.rb +1 -1
- data/lib/oboe/inst/cassandra.rb +3 -3
- data/lib/oboe/inst/dalli.rb +1 -1
- data/lib/oboe/inst/memcache.rb +1 -1
- data/lib/oboe/inst/moped.rb +30 -10
- data/lib/oboe/inst/resque.rb +1 -1
- data/lib/oboe/version.rb +3 -3
- data/lib/oboe_metal.rb +35 -0
- data/oboe.gemspec +4 -3
- data/test/frameworks/apps/grape_simple.rb +0 -2
- data/test/instrumentation/cassandra_test.rb +297 -293
- data/test/instrumentation/dalli_test.rb +1 -1
- data/test/instrumentation/memcached_test.rb +1 -1
- data/test/instrumentation/moped_test.rb +1 -1
- data/test/instrumentation/rack_test.rb +9 -0
- data/test/minitest_helper.rb +9 -19
- data/test/support/liboboe_settings_test.rb +33 -28
- metadata +4 -4
- data/Gemfile.lock +0 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7835aa1d91871340702efcd183ca19671ed7657d
|
4
|
+
data.tar.gz: 9e798783e0b7a3b00b24a73e85e689161911cef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa269012fc13f4b4c27e2daff5270802d9875d3f04827a461245982e55f26f5cb57c495f59c153add71ed4a13d63d447d67b0f0a43b7134efd88d61cac8bdd52
|
7
|
+
data.tar.gz: 406c373f4c9325c526448b59776b08edc05d4e334e50924d677a0b65a283ae114c4a71861215ebfbf08cdc92552a1d99381f4cd41f451e46ea84d347c8369570
|
data/.travis.yml
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
3
|
+
cache:
|
4
|
+
bundler: true
|
5
|
+
directories:
|
6
|
+
- vendor/bundle
|
7
|
+
|
2
8
|
rvm:
|
3
9
|
- 2.1.1
|
4
10
|
- 2.0.0
|
@@ -6,6 +12,7 @@ rvm:
|
|
6
12
|
- 1.9.2
|
7
13
|
- 1.8.7
|
8
14
|
- ree
|
15
|
+
- jruby-19mode
|
9
16
|
|
10
17
|
#gemfile:
|
11
18
|
# - gemfiles/mongo.gemfile
|
@@ -25,6 +32,7 @@ before_script: sleep 10
|
|
25
32
|
install:
|
26
33
|
- wget https://www.tracelytics.com/install_tracelytics.sh
|
27
34
|
- sudo sh ./install_tracelytics.sh f51e2a43-0ee5-4851-8a54-825773b3218e
|
35
|
+
- sudo apt-get install -y tracelytics-java-agent
|
28
36
|
|
29
37
|
before_script:
|
30
38
|
- bundle install --without development
|
@@ -38,3 +46,6 @@ services:
|
|
38
46
|
- cassandra
|
39
47
|
- redis
|
40
48
|
|
49
|
+
matrix:
|
50
|
+
allow_failures:
|
51
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# oboe 2.7.0 (08/13/2014)
|
2
|
+
|
3
|
+
This minor release includes:
|
4
|
+
|
5
|
+
* [JRuby instrumentation](https://github.com/appneta/oboe-ruby/pull/51) is back and better than ever
|
6
|
+
* [Updated moped instrumentation](https://github.com/appneta/oboe-ruby/pull/63) to support moped v2 changes
|
7
|
+
* Simplify start_trace by setting a default param: [#67](https://github.com/appneta/oboe-ruby/pull/67)
|
8
|
+
|
9
|
+
Pushed to Rubygems: https://rubygems.org/gems/oboe/versions/2.7.0
|
10
|
+
|
11
|
+
# oboe 2.6.8 (07/31/2014)
|
12
|
+
|
13
|
+
This patch release includes:
|
14
|
+
|
15
|
+
* Fix [instrumentation load for Padrino in test environments](https://github.com/appneta/oboe-ruby/pull/65)
|
16
|
+
* [Add delay](https://github.com/appneta/oboe-ruby/pull/66) in test suite to allow downloading of sample rate info
|
17
|
+
|
18
|
+
Pushed to Rubygems: https://rubygems.org/gems/oboe/versions/2.6.8
|
19
|
+
|
1
20
|
# oboe 2.6.7.1 (07/23/2014)
|
2
21
|
|
3
22
|
This patch release includes better error handling, API clean-up and RUM template improvements.
|
data/Gemfile
CHANGED
@@ -8,8 +8,8 @@ group :development, :test do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
group :development do
|
11
|
-
gem 'ruby-debug', :
|
12
|
-
gem 'debugger', :platform =>
|
11
|
+
gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
|
12
|
+
gem 'debugger', :platform => :mri_19
|
13
13
|
gem 'byebug', :platforms => [ :mri_20, :mri_21 ]
|
14
14
|
gem 'perftools.rb', :platforms => [ :mri_20, :mri_21 ], :require => 'perftools'
|
15
15
|
gem 'pry'
|
@@ -18,15 +18,24 @@ end
|
|
18
18
|
# Instrumented gems
|
19
19
|
gem 'dalli'
|
20
20
|
gem 'memcache-client'
|
21
|
-
gem 'memcached', '1.7.2' if RUBY_VERSION < '2.0.0'
|
22
21
|
gem 'cassandra'
|
23
22
|
gem 'mongo'
|
24
|
-
gem 'moped'
|
23
|
+
gem 'moped' if RUBY_VERSION >= '1.9'
|
25
24
|
gem 'resque'
|
26
25
|
gem 'redis'
|
27
26
|
|
27
|
+
unless defined?(JRUBY_VERSION)
|
28
|
+
gem 'memcached', '1.7.2' if RUBY_VERSION < '2.0.0'
|
29
|
+
gem 'bson_ext' # For Mongo, Yours Truly
|
30
|
+
end
|
31
|
+
|
28
32
|
# Instrumented Frameworks
|
29
|
-
|
33
|
+
|
34
|
+
if defined?(JRUBY_VERSION)
|
35
|
+
gem 'sinatra', :require => false
|
36
|
+
else
|
37
|
+
gem 'sinatra'
|
38
|
+
end
|
30
39
|
|
31
40
|
if RUBY_VERSION >= '1.9.3'
|
32
41
|
gem 'padrino', '0.12.0'
|
@@ -36,6 +45,5 @@ else
|
|
36
45
|
gem 'bson', '1.10.2'
|
37
46
|
end
|
38
47
|
|
39
|
-
|
40
|
-
gemspec :name => 'oboe'
|
48
|
+
gemspec
|
41
49
|
|
data/README.md
CHANGED
@@ -21,19 +21,21 @@ The oboe gem is [available on Rubygems](https://rubygems.org/gems/oboe) and can
|
|
21
21
|
gem install oboe
|
22
22
|
```
|
23
23
|
|
24
|
-
or added to your bundle Gemfile and running `bundle install`:
|
24
|
+
or added to _the end_ of your bundle Gemfile and running `bundle install`:
|
25
25
|
|
26
26
|
```ruby
|
27
27
|
gem 'oboe'
|
28
28
|
```
|
29
29
|
|
30
|
+
On Heroku? Use the `oboe-heroku` gem instead. It wraps some additional functionality specialized for Heroku.
|
31
|
+
|
30
32
|
# Running
|
31
33
|
|
32
34
|
## Rails
|
33
35
|
|
34
36
|
No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the oboe gem will automatically detect Rails and instrument on stack initialization.
|
35
37
|
|
36
|
-
*Note:
|
38
|
+
*Note: Unless you are Heroku, you will still need to decide on your `tracing_mode` depending on whether you are running with an instrumented Apache or nginx in front of your Rails stack. See below for more details.*
|
37
39
|
|
38
40
|
### The Install Generator
|
39
41
|
|
@@ -62,15 +64,11 @@ require 'oboe'
|
|
62
64
|
# order to initiate tracing.
|
63
65
|
Oboe::Config[:tracing_mode] = 'through'
|
64
66
|
|
65
|
-
# You can remove the following line in production to allow for
|
66
|
-
# auto sampling or managing the sample rate through the TraceView portal.
|
67
|
-
# Oboe::Config[:sample_rate] = 1000000
|
68
|
-
|
69
67
|
# You may want to replace the Oboe.logger with whichever logger you are using
|
70
68
|
# Oboe.logger = Sinatra.logger
|
71
69
|
```
|
72
70
|
|
73
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode`
|
71
|
+
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
74
72
|
|
75
73
|
Make sure that the oboe gem is loaded _after_ Sinatra either by listing `gem 'oboe'` after Sinatra in your Gemfile or calling the `require 'oboe'` directive after Sinatra is loaded.
|
76
74
|
|
@@ -90,14 +88,10 @@ Padrino.before_load do
|
|
90
88
|
# from upstream) and "never". You must set this directive to "always" in
|
91
89
|
# order to initiate tracing.
|
92
90
|
Oboe::Config[:tracing_mode] = 'always'
|
93
|
-
|
94
|
-
# You can remove the following line in production to allow for
|
95
|
-
# auto sampling or managing the sample rate through the TraceView portal.
|
96
|
-
Oboe::Config[:sample_rate] = 1e6
|
97
91
|
end
|
98
92
|
```
|
99
93
|
|
100
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode`
|
94
|
+
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
101
95
|
|
102
96
|
## Grape
|
103
97
|
|
@@ -114,10 +108,6 @@ You can instrument your Grape application by adding the following code to your `
|
|
114
108
|
# order to initiate tracing.
|
115
109
|
Oboe::Config[:tracing_mode] = 'through'
|
116
110
|
|
117
|
-
# You can remove the following line in production to allow for
|
118
|
-
# auto sampling or managing the sample rate through the TraceView portal.
|
119
|
-
# Oboe::Config[:sample_rate] = 1000000
|
120
|
-
|
121
111
|
...
|
122
112
|
|
123
113
|
class App < Grape::API
|
@@ -125,7 +115,7 @@ You can instrument your Grape application by adding the following code to your `
|
|
125
115
|
end
|
126
116
|
```
|
127
117
|
|
128
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode`
|
118
|
+
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
129
119
|
|
130
120
|
Make sure that the oboe gem is loaded _after_ Grape either by listing `gem 'oboe'` after Grape in your Gemfile or calling the `require 'oboe'` directive after Grape is loaded.
|
131
121
|
|
@@ -146,9 +136,6 @@ require 'oboe'
|
|
146
136
|
# Tracing mode can be 'never', 'through' (to follow upstream) or 'always'
|
147
137
|
Oboe::Config[:tracing_mode] = 'always'
|
148
138
|
|
149
|
-
# Number of requests to trace out of each million
|
150
|
-
Oboe::Config[:sample_rate] = 1000000
|
151
|
-
|
152
139
|
Oboe::Ruby.initialize
|
153
140
|
```
|
154
141
|
|
data/Rakefile
CHANGED
@@ -9,6 +9,9 @@ Rake::TestTask.new do |t|
|
|
9
9
|
t.libs << "test"
|
10
10
|
t.test_files = FileList['test/**/*_test.rb']
|
11
11
|
t.verbose = true
|
12
|
+
if defined?(JRUBY_VERSION)
|
13
|
+
t.ruby_opts = ["-J-javaagent:/usr/local/tracelytics/tracelyticsagent.jar"]
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
|
@@ -19,62 +22,74 @@ end
|
|
19
22
|
|
20
23
|
desc "Build the gem's c extension"
|
21
24
|
task :compile do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
File.
|
38
|
-
|
39
|
-
|
25
|
+
unless defined?(JRUBY_VERSION)
|
26
|
+
puts "== Building the c extension against Ruby #{RUBY_VERSION}"
|
27
|
+
|
28
|
+
pwd = Dir.pwd
|
29
|
+
ext_dir = File.expand_path('ext/oboe_metal')
|
30
|
+
lib_dir = File.expand_path('lib')
|
31
|
+
symlink = File.expand_path('lib/oboe_metal.so')
|
32
|
+
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
|
33
|
+
|
34
|
+
Dir.chdir ext_dir
|
35
|
+
cmd = [ Gem.ruby, 'extconf.rb']
|
36
|
+
sh cmd.join(' ')
|
37
|
+
sh '/usr/bin/env make'
|
38
|
+
File.delete symlink if File.exist? symlink
|
39
|
+
|
40
|
+
if File.exists? so_file
|
41
|
+
File.symlink so_file, symlink
|
42
|
+
Dir.chdir pwd
|
43
|
+
puts "== Extension built and symlink'd to #{symlink}"
|
44
|
+
else
|
45
|
+
Dir.chdir pwd
|
46
|
+
puts "!! Extension failed to build (see above). Are the base TraceView packages installed?"
|
47
|
+
puts "!! See https://support.appneta.com/cloud/installing-traceview"
|
48
|
+
end
|
40
49
|
else
|
41
|
-
|
42
|
-
puts "!! Extension failed to build (see above). Are the base TraceView packages installed?"
|
43
|
-
puts "!! See https://support.appneta.com/cloud/installing-traceview"
|
50
|
+
puts "== Nothing to do under JRuby."
|
44
51
|
end
|
45
52
|
end
|
46
53
|
|
47
54
|
desc "Clean up extension build files"
|
48
55
|
task :clean do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
56
|
+
unless defined?(JRUBY_VERSION)
|
57
|
+
pwd = Dir.pwd
|
58
|
+
ext_dir = File.expand_path('ext/oboe_metal')
|
59
|
+
lib_dir = File.expand_path('lib')
|
60
|
+
symlink = File.expand_path('lib/oboe_metal.so')
|
61
|
+
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
|
54
62
|
|
55
|
-
|
56
|
-
|
63
|
+
Dir.chdir ext_dir
|
64
|
+
sh '/usr/bin/env make clean'
|
57
65
|
|
58
|
-
|
66
|
+
Dir.chdir pwd
|
67
|
+
else
|
68
|
+
puts "== Nothing to do under JRuby."
|
69
|
+
end
|
59
70
|
end
|
60
71
|
|
61
72
|
desc "Remove all built files and extensions"
|
62
73
|
task :distclean do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
unless defined?(JRUBY_VERSION)
|
75
|
+
pwd = Dir.pwd
|
76
|
+
ext_dir = File.expand_path('ext/oboe_metal')
|
77
|
+
lib_dir = File.expand_path('lib')
|
78
|
+
symlink = File.expand_path('lib/oboe_metal.so')
|
79
|
+
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
|
80
|
+
mkmf_log = File.expand_path('ext/oboe_metal/mkmf.log')
|
81
|
+
|
82
|
+
if File.exists? mkmf_log
|
83
|
+
Dir.chdir ext_dir
|
84
|
+
File.delete symlink if File.exist? symlink
|
85
|
+
sh '/usr/bin/env make distclean'
|
86
|
+
|
87
|
+
Dir.chdir pwd
|
88
|
+
else
|
89
|
+
puts "Nothing to distclean. (nothing built yet?)"
|
90
|
+
end
|
76
91
|
else
|
77
|
-
puts "Nothing to
|
92
|
+
puts "== Nothing to do under JRuby."
|
78
93
|
end
|
79
94
|
end
|
80
95
|
|
data/ext/oboe_metal/extconf.rb
CHANGED
@@ -5,12 +5,7 @@ require 'mkmf'
|
|
5
5
|
require 'rbconfig'
|
6
6
|
|
7
7
|
# Check if we're running in JRuby
|
8
|
-
|
9
|
-
# nil meaning java string not found
|
10
|
-
jruby = (RbConfig::CONFIG['arch'] =~ /java/i) != nil
|
11
|
-
else
|
12
|
-
jruby = false
|
13
|
-
end
|
8
|
+
jruby = defined?(JRUBY_VERSION) ? true : false
|
14
9
|
|
15
10
|
openshift = ENV.has_key?('OPENSHIFT_TRACEVIEW_DIR')
|
16
11
|
|
data/lib/base.rb
CHANGED
@@ -22,32 +22,25 @@ SAMPLE_SOURCE_MASK = 0b1111000000000000000000000000
|
|
22
22
|
ZERO_SAMPLE_RATE_MASK = 0b1111000000000000000000000000
|
23
23
|
ZERO_SAMPLE_SOURCE_MASK = 0b0000111111111111111111111111
|
24
24
|
|
25
|
-
module Oboe_metal
|
26
|
-
class Context
|
27
|
-
class << self
|
28
|
-
attr_accessor :layer_op
|
29
|
-
|
30
|
-
def tracing_layer_op?(operation)
|
31
|
-
if operation.is_a?(Array)
|
32
|
-
return operation.include?(@layer_op)
|
33
|
-
else
|
34
|
-
return @layer_op == operation
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
25
|
module OboeBase
|
42
26
|
attr_accessor :reporter
|
43
27
|
attr_accessor :loaded
|
44
28
|
attr_accessor :sample_source
|
45
29
|
attr_accessor :sample_rate
|
30
|
+
attr_accessor :layer_op
|
46
31
|
|
47
32
|
def self.included(cls)
|
48
33
|
self.loaded = true
|
49
34
|
end
|
50
35
|
|
36
|
+
def tracing_layer_op?(operation)
|
37
|
+
if operation.is_a?(Array)
|
38
|
+
return operation.include?(@layer_op)
|
39
|
+
else
|
40
|
+
return @layer_op == operation
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
51
44
|
def always?
|
52
45
|
Oboe::Config[:tracing_mode].to_s == "always"
|
53
46
|
end
|
@@ -102,6 +95,5 @@ module OboeBase
|
|
102
95
|
def set_sample_rate(rate)
|
103
96
|
raise "set_sample_rate should be implemented by metal layer."
|
104
97
|
end
|
105
|
-
|
106
98
|
end
|
107
99
|
|
data/lib/joboe_metal.rb
CHANGED
@@ -5,18 +5,20 @@ require 'base'
|
|
5
5
|
|
6
6
|
module Oboe_metal
|
7
7
|
include_package 'com.tracelytics.joboe'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
include_package 'com.tracelytics.joboe.Event'
|
14
|
-
import 'com.tracelytics.joboe.Event'
|
8
|
+
java_import 'com.tracelytics.joboe.LayerUtil'
|
9
|
+
java_import 'com.tracelytics.joboe.SettingsReader'
|
10
|
+
java_import 'com.tracelytics.joboe.Context'
|
11
|
+
java_import 'com.tracelytics.joboe.Event'
|
12
|
+
java_import 'com.tracelytics.agent.Agent'
|
15
13
|
|
16
14
|
class Context
|
17
15
|
class << self
|
18
16
|
def toString
|
19
|
-
md = getMetadata.
|
17
|
+
md = getMetadata.toHexString
|
18
|
+
end
|
19
|
+
|
20
|
+
def fromString(xtrace)
|
21
|
+
Context.setMetadata(xtrace)
|
20
22
|
end
|
21
23
|
|
22
24
|
def clear
|
@@ -51,14 +53,30 @@ module Oboe_metal
|
|
51
53
|
begin
|
52
54
|
return unless Oboe.loaded
|
53
55
|
|
54
|
-
Oboe_metal::Context.init()
|
55
|
-
|
56
56
|
if ENV.has_key?("OBOE_GEM_TEST")
|
57
|
-
Oboe.reporter =
|
57
|
+
Oboe.reporter = Java::ComTracelyticsJoboe::TestReporter.new
|
58
|
+
else
|
59
|
+
Oboe.reporter = Java::ComTracelyticsJoboe::ReporterFactory.getInstance().buildUdpReporter()
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
# Import the tracing mode and sample rate settings
|
64
|
+
# from the Java agent (user configured in
|
65
|
+
# /usr/local/tracelytics/javaagent.json when under JRuby)
|
66
|
+
cfg = LayerUtil.getLocalSampleRate(nil, nil)
|
67
|
+
|
68
|
+
if cfg.hasSampleStartFlag
|
69
|
+
Oboe::Config.tracing_mode = 'always'
|
70
|
+
elsif cfg.hasSampleThroughFlag
|
71
|
+
Oboe::Config.tracing_mode = 'through'
|
58
72
|
else
|
59
|
-
Oboe.
|
73
|
+
Oboe::Config.tracing_mode = 'never'
|
60
74
|
end
|
61
75
|
|
76
|
+
Oboe.sample_rate = cfg.sampleRate
|
77
|
+
Oboe::Config.sample_rate = cfg.sampleRate
|
78
|
+
Oboe::Config.sample_source = cfg.sampleRateSource.a
|
79
|
+
|
62
80
|
# Only report __Init from here if we are not instrumenting a framework.
|
63
81
|
# Otherwise, frameworks will handle reporting __Init after full initialization
|
64
82
|
unless defined?(::Rails) or defined?(::Sinatra) or defined?(::Padrino) or defined?(::Grape)
|
@@ -71,8 +89,41 @@ module Oboe_metal
|
|
71
89
|
end
|
72
90
|
end
|
73
91
|
|
92
|
+
##
|
93
|
+
# clear_all_traces
|
94
|
+
#
|
95
|
+
# Truncates the trace output file to zero
|
96
|
+
#
|
97
|
+
def self.clear_all_traces
|
98
|
+
Oboe.reporter.reset if Oboe.loaded
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# get_all_traces
|
103
|
+
#
|
104
|
+
# Retrieves all traces written to the trace file
|
105
|
+
#
|
106
|
+
def self.get_all_traces
|
107
|
+
return [] unless Oboe.loaded
|
108
|
+
|
109
|
+
# Joboe TestReporter returns a Java::ComTracelyticsExtEbson::DefaultDocument
|
110
|
+
# document for traces which doesn't correctly support things like has_key? which
|
111
|
+
# raises an unhandled exception on non-existent key (duh). Here we convert
|
112
|
+
# the Java::ComTracelyticsExtEbson::DefaultDocument doc to a pure array of Ruby
|
113
|
+
# hashes
|
114
|
+
traces = []
|
115
|
+
Oboe.reporter.getSentEventsAsBsonDocument.to_a.each do |e|
|
116
|
+
t = {}
|
117
|
+
e.each_pair { |k,v|
|
118
|
+
t[k] = v
|
119
|
+
}
|
120
|
+
traces << t
|
121
|
+
end
|
122
|
+
traces
|
123
|
+
end
|
124
|
+
|
74
125
|
def self.sendReport(evt)
|
75
|
-
evt.report
|
126
|
+
evt.report(Oboe.reporter)
|
76
127
|
end
|
77
128
|
end
|
78
129
|
end
|
@@ -83,23 +134,52 @@ module Oboe
|
|
83
134
|
|
84
135
|
class << self
|
85
136
|
def sample?(opts = {})
|
86
|
-
|
137
|
+
begin
|
138
|
+
return false unless Oboe.always? and Oboe.loaded
|
139
|
+
|
140
|
+
return true if ENV['OBOE_GEM_TEST'] == "test"
|
141
|
+
|
142
|
+
# Validation to make Joboe happy. Assure that we have the KVs and that they
|
143
|
+
# are not empty strings.
|
144
|
+
opts[:layer] = nil if opts[:layer].is_a?(String) and opts[:layer].empty?
|
145
|
+
opts[:xtrace] = nil if opts[:xtrace].is_a?(String) and opts[:xtrace].empty?
|
146
|
+
opts['X-TV-Meta'] = nil if opts['X-TV-Meta'].is_a?(String) and opts['X-TV-Meta'].empty?
|
87
147
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
148
|
+
opts[:layer] ||= nil
|
149
|
+
opts[:xtrace] ||= nil
|
150
|
+
opts['X-TV-Meta'] ||= nil
|
151
|
+
|
152
|
+
sr_cfg = Java::ComTracelyticsJoboe::LayerUtil.shouldTraceRequest( opts[:layer],
|
153
|
+
{ 'X-Trace' => opts[:xtrace], 'X-TV-Meta' => opts['X-TV-Meta'] } )
|
154
|
+
|
155
|
+
# Store the returned SampleRateConfig into Oboe::Config
|
156
|
+
if sr_cfg
|
157
|
+
Oboe.sample_rate = sr_cfg.sampleRate
|
158
|
+
Oboe.sample_source = sr_cfg.sampleRateSource.a
|
159
|
+
end
|
160
|
+
|
161
|
+
sr_cfg
|
162
|
+
rescue => e
|
163
|
+
Oboe.logger.debug "[oboe/debug] #{e.message}"
|
164
|
+
false
|
165
|
+
end
|
93
166
|
end
|
94
167
|
|
95
168
|
def set_tracing_mode(mode)
|
96
|
-
|
169
|
+
Oboe.logger.warn "When using JRuby set the tracing mode in /usr/local/tracelytics/javaagent.json instead"
|
97
170
|
end
|
98
171
|
|
99
172
|
def set_sample_rate(rate)
|
100
|
-
#
|
173
|
+
# N/A
|
101
174
|
end
|
102
175
|
end
|
103
176
|
end
|
104
177
|
|
105
|
-
|
178
|
+
# Assure that the Joboe Java Agent was loaded via premain
|
179
|
+
status = Java::ComTracelyticsAgent::Agent.getStatus
|
180
|
+
if status == Java::ComTracelyticsAgent::Agent::AgentStatus::UNINITIALIZED
|
181
|
+
Oboe.loaded = false
|
182
|
+
else
|
183
|
+
Oboe.loaded = true
|
184
|
+
end
|
185
|
+
|