appoptics_apm 4.8.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -1
- data/.irbrc +3 -0
- data/.travis.yml +39 -24
- data/CONFIG.md +1 -1
- data/README.md +1 -1
- data/Rakefile +60 -53
- data/appoptics_apm.gemspec +1 -1
- data/build_gem_upload_to_packagecloud.sh +1 -6
- data/examples/SDK/01_basic_tracing.rb +0 -2
- data/ext/oboe_metal/README.md +69 -0
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/oboe.h +102 -71
- data/ext/oboe_metal/src/oboe.hpp +111 -69
- data/ext/oboe_metal/src/oboe_wrap.cxx +1470 -314
- data/lib/appoptics_apm.rb +1 -0
- data/lib/appoptics_apm/config.rb +11 -4
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +4 -4
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +2 -2
- data/lib/appoptics_apm/inst/logger_formatter.rb +4 -3
- data/lib/appoptics_apm/inst/rack.rb +11 -11
- data/lib/appoptics_apm/oboe_init_options.rb +17 -4
- data/lib/appoptics_apm/support/transaction_settings.rb +40 -16
- data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
- data/lib/appoptics_apm/version.rb +1 -1
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +37 -12
- data/oboe.code-workspace +66 -0
- data/scrap.rb +134 -0
- data/scrap_gemfile +5 -0
- data/scrap_gemfile.lock +140 -0
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4b87b6581745b8485f7ddb38f17cb6eab85244a950e7d67cecfe0e97cdbd0bc
|
4
|
+
data.tar.gz: dce765afa7ceb92b523c448cd9b1b10efc1b6c5bb0f2f92842dc6af3c1934b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b446519730872b09136e9b80e546a68dce40abf52fbb0e5ac139244c6ed3c7fa8ef45eb855714d8e11924886d0b972aa04332cec6342339c65772f5b7aec0f
|
7
|
+
data.tar.gz: 80df368e2ed2c868348ba5e7e9b24dfa2498d6f0cb703d568fbf8310879d06fee5ac59187a70747f04c040d4d54df2b8925faa856dc5a01b036375f21edacfbe
|
data/.gitignore
CHANGED
data/.irbrc
ADDED
data/.travis.yml
CHANGED
@@ -11,8 +11,8 @@ env:
|
|
11
11
|
- DBTYPE=mysql
|
12
12
|
|
13
13
|
rvm:
|
14
|
-
- 2.6.
|
15
|
-
- 2.5.
|
14
|
+
- 2.6.4
|
15
|
+
- 2.5.5
|
16
16
|
- 2.4.5
|
17
17
|
- ruby-head
|
18
18
|
# - jruby-9.0.5.0
|
@@ -23,6 +23,7 @@ gemfile:
|
|
23
23
|
- gemfiles/instrumentation_mocked.gemfile
|
24
24
|
- gemfiles/instrumentation_mocked_oldgems.gemfile
|
25
25
|
- gemfiles/frameworks.gemfile
|
26
|
+
- gemfiles/rails60.gemfile
|
26
27
|
- gemfiles/rails52.gemfile
|
27
28
|
- gemfiles/rails42.gemfile
|
28
29
|
- gemfiles/delayed_job.gemfile
|
@@ -32,13 +33,14 @@ matrix:
|
|
32
33
|
exclude:
|
33
34
|
- rvm: ruby-head
|
34
35
|
gemfile: gemfiles/rails42.gemfile
|
35
|
-
- rvm: 2.6.
|
36
|
+
- rvm: 2.6.4
|
36
37
|
gemfile: gemfiles/rails42.gemfile
|
38
|
+
- rvm: 2.4.5
|
39
|
+
gemfile: gemfiles/rails60.gemfile
|
37
40
|
|
38
|
-
|
39
|
-
- rmv: 2.6.2
|
41
|
+
- rmv: 2.6.4
|
40
42
|
env: DBTYPE=mysql
|
41
|
-
- rvm: 2.5.
|
43
|
+
- rvm: 2.5.5
|
42
44
|
env: DBTYPE=mysql
|
43
45
|
- rvm: 2.4.5
|
44
46
|
env: DBTYPE=mysql
|
@@ -57,10 +59,10 @@ matrix:
|
|
57
59
|
env: DBTYPE=mysql
|
58
60
|
- gemfile: gemfiles/frameworks.gemfile
|
59
61
|
env: DBTYPE=mysql
|
60
|
-
- gemfile: gemfiles/rails51.gemfile
|
61
|
-
env: DBTYPE=mysql
|
62
62
|
- gemfile: gemfiles/rails52.gemfile
|
63
63
|
env: DBTYPE=mysql
|
64
|
+
- gemfile: gemfiles/rails60.gemfile
|
65
|
+
env: DBTYPE=mysql
|
64
66
|
- gemfile: gemfiles/delayed_job.gemfile
|
65
67
|
env: DBTYPE=mysql
|
66
68
|
|
@@ -85,37 +87,50 @@ matrix:
|
|
85
87
|
# Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484
|
86
88
|
# Updated Cassandra: https://github.com/travis-ci/travis-ci/issues/1650
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
-
|
93
|
-
- sudo
|
90
|
+
# the following is not working anymore on travis
|
91
|
+
# commenting it out as per AO-13532 as we currently don't have instrumentation
|
92
|
+
# for cassandra
|
93
|
+
#before_install:
|
94
|
+
# - sudo service cassandra stop
|
95
|
+
# - sudo sh -c "echo 'JVM_OPTS=\"\${JVM_OPTS} -Djava.net.preferIPv4Stack=false\"' >> /etc/cassandra/cassandra-env.sh"
|
96
|
+
# - echo "127.0.0.1 localhost" | sudo tee /etc/hosts
|
97
|
+
# - echo "127.0.0.1 " `hostname` | sudo tee -a /etc/hosts
|
98
|
+
# - sudo service cassandra start
|
94
99
|
|
95
100
|
install:
|
96
|
-
- curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.
|
97
|
-
- tar xzf swig-3.0.
|
98
|
-
- pushd swig-3.0.
|
101
|
+
- curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz
|
102
|
+
- tar xzf swig-3.0.12.tar.gz
|
103
|
+
- pushd swig-3.0.12
|
99
104
|
- ./configure && make && sudo make install
|
100
105
|
- popd
|
101
106
|
|
102
107
|
before_script:
|
108
|
+
- export APPOPTICS_GEM_TEST=true
|
109
|
+
- export APPOPTICS_REPORTER=file
|
110
|
+
- export APPOPTICS_COLLECTOR=/tmp/appoptics_traces.bson
|
111
|
+
- export APPOPTICS_REPORTER_FILE_SINGLE=false
|
112
|
+
- export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
|
113
|
+
- export APPOPTICS_TOKEN_BUCKET_RATE=1000
|
114
|
+
|
103
115
|
- bundle update --jobs=3 --retry=3
|
104
|
-
- bundle exec rake
|
105
|
-
- bundle exec rake clean
|
106
|
-
- bundle exec rake compile
|
116
|
+
- bundle exec rake clean fetch compile
|
107
117
|
- psql -c 'create database travis_ci_test;' -U postgres
|
108
118
|
- mysql -e 'create database travis_ci_test;'
|
109
119
|
- redis-server --requirepass secret_pass &
|
110
120
|
- sleep 10
|
111
|
-
- export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
|
112
|
-
- export APPOPTICS_TOKEN_BUCKET_RATE=1000
|
113
121
|
|
114
122
|
script: "N=1 bundle exec rake test"
|
115
123
|
|
116
124
|
services:
|
117
125
|
- mongodb
|
118
126
|
- memcached
|
119
|
-
-
|
120
|
-
# -
|
127
|
+
- mysql
|
128
|
+
# - cassandra
|
129
|
+
- postgresql
|
130
|
+
# - redis-server
|
121
131
|
- rabbitmq
|
132
|
+
|
133
|
+
addons:
|
134
|
+
apt:
|
135
|
+
packages:
|
136
|
+
- rabbitmq-server
|
data/CONFIG.md
CHANGED
@@ -17,7 +17,7 @@ Name | Description | Default
|
|
17
17
|
|
18
18
|
Name | Description | Default
|
19
19
|
---- | ----------- | -------
|
20
|
-
`APPOPTICS_GEM_TEST` | puts the gem in test mode
|
20
|
+
`APPOPTICS_GEM_TEST` | puts the gem in test mode to avoid restarting certain background services used in testing. `false`
|
21
21
|
`DBTYPE` | For tests on Ruby on Rails, specifies the database type to test against. `postgres`, `mysql` and `mysql2` are valid options. | `postgres`
|
22
22
|
`APPOPTICS_CASSANDRA_SERVER` | specifies the Cassandra server to test against. | `127.0.0.1:9160`
|
23
23
|
`APPOPTICS_MONGO_SERVER` | specifies the Mongo server to test against. | `127.0.0.1:27017`
|
data/README.md
CHANGED
@@ -390,4 +390,4 @@ See the README in the test directory.
|
|
390
390
|
|
391
391
|
Copyright (c) 2018 SolarWinds, LLC
|
392
392
|
|
393
|
-
Released under the [Librato Open License](https://docs.appoptics.com/kb/apm_tracing/librato-open-license/)
|
393
|
+
Released under the [Librato Open License](https://docs.appoptics.com/kb/apm_tracing/librato-open-license/)
|
data/Rakefile
CHANGED
@@ -31,6 +31,9 @@ Rake::TestTask.new do |t|
|
|
31
31
|
if Rails::VERSION::MAJOR == 5
|
32
32
|
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"] +
|
33
33
|
FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_api_test.rb"]
|
34
|
+
elsif Rails::VERSION::MAJOR == 6
|
35
|
+
t.test_files = FileList["test/frameworks/rails5x_test.rb"] +
|
36
|
+
FileList["test/frameworks/rails5x_api_test.rb"]
|
34
37
|
else
|
35
38
|
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"]
|
36
39
|
end
|
@@ -56,74 +59,77 @@ Rake::TestTask.new do |t|
|
|
56
59
|
end
|
57
60
|
|
58
61
|
if defined?(JRUBY_VERSION)
|
59
|
-
|
62
|
+
t.ruby_opts << ['-J-javaagent:/usr/local/tracelytics/tracelyticsagent.jar']
|
63
|
+
end
|
60
64
|
end
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "Run all test suites defined by travis"
|
64
|
-
task "docker_tests" do
|
65
|
-
Dir.chdir('test/run_tests')
|
66
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
67
|
-
end
|
68
65
|
|
69
|
-
desc "Start docker container for testing and debugging"
|
70
|
-
task "docker" do
|
71
|
-
Dir.chdir('test/run_tests')
|
72
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
73
|
-
end
|
74
66
|
|
75
|
-
desc "
|
76
|
-
task "
|
77
|
-
|
78
|
-
|
79
|
-
end
|
67
|
+
desc "Run all test suites defined by travis"
|
68
|
+
task "docker_tests" do
|
69
|
+
Dir.chdir('test/run_tests')
|
70
|
+
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
71
|
+
end
|
80
72
|
|
81
|
-
desc "
|
82
|
-
task
|
83
|
-
|
84
|
-
|
85
|
-
if swig_version.empty?
|
86
|
-
$stderr.puts '== ERROR ================================================================='
|
87
|
-
$stderr.puts "Could not find required swig version 3.0.*, found #{swig_version.inspect}"
|
88
|
-
$stderr.puts 'Please install swig "~ 3.0.8" and try again.'
|
89
|
-
$stderr.puts '=========================================================================='
|
90
|
-
raise
|
73
|
+
desc "Start docker container for testing and debugging"
|
74
|
+
task "docker" do
|
75
|
+
Dir.chdir('test/run_tests')
|
76
|
+
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
91
77
|
end
|
92
78
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# VERSION is used by extconf.rb to download the correct liboboe when installing the gem
|
99
|
-
remote_file = File.join(oboe_s3_dir, 'VERSION')
|
100
|
-
local_file = File.join(ext_src_dir, 'VERSION')
|
101
|
-
puts "fetching #{remote_file} to #{local_file}"
|
102
|
-
open(remote_file, 'rb') do |rf|
|
103
|
-
content = rf.read
|
104
|
-
File.open(local_file, 'wb') { |f| f.puts content }
|
105
|
-
puts "!!!!!!! C-Lib VERSION: #{content.strip} !!!!!!!!"
|
79
|
+
desc "Stop all containers that were started for testing and debugging"
|
80
|
+
task "docker_down" do
|
81
|
+
Dir.chdir('test/run_tests')
|
82
|
+
exec('docker-compose down')
|
106
83
|
end
|
107
84
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
85
|
+
desc "Fetch extension dependency files"
|
86
|
+
task :fetch_ext_deps do
|
87
|
+
swig_version = %x{swig -version} rescue ''
|
88
|
+
swig_version = swig_version.scan(/swig version [34].0.\d*/i)
|
89
|
+
if swig_version.empty?
|
90
|
+
$stderr.puts '== ERROR ================================================================='
|
91
|
+
$stderr.puts "Could not find required swig version >3.0.8, found #{swig_version.inspect}"
|
92
|
+
$stderr.puts 'Please install swig "~ 3.0.12" and try again.'
|
93
|
+
$stderr.puts '=========================================================================='
|
94
|
+
raise
|
95
|
+
end
|
96
|
+
|
97
|
+
# The c-lib version is different from the gem version
|
98
|
+
oboe_version = ENV['OBOE_VERSION'] || 'latest'
|
99
|
+
oboe_s3_dir = "https://s3-us-west-2.amazonaws.com/rc-files-t2/c-lib/#{oboe_version}"
|
100
|
+
ext_src_dir = File.expand_path('ext/oboe_metal/src')
|
114
101
|
|
102
|
+
# VERSION is used by extconf.rb to download the correct liboboe when installing the gem
|
103
|
+
remote_file = File.join(oboe_s3_dir, 'VERSION')
|
104
|
+
local_file = File.join(ext_src_dir, 'VERSION')
|
115
105
|
puts "fetching #{remote_file} to #{local_file}"
|
116
106
|
open(remote_file, 'rb') do |rf|
|
117
107
|
content = rf.read
|
118
108
|
File.open(local_file, 'wb') { |f| f.puts content }
|
109
|
+
puts "!!!!!!! C-Lib VERSION: #{content.strip} !!!!!!!!"
|
110
|
+
end
|
111
|
+
|
112
|
+
# oboe and bson header files
|
113
|
+
FileUtils.mkdir_p(File.join(ext_src_dir, 'bson'))
|
114
|
+
%w(oboe.h oboe.hpp oboe_debug.h oboe.i bson/bson.h bson/platform_hacks.h).each do |filename|
|
115
|
+
# %w(oboe.h oboe_debug.h bson/bson.h bson/platform_hacks.h).each do |filename|
|
116
|
+
remote_file = File.join(oboe_s3_dir, 'include', filename)
|
117
|
+
local_file = File.join(ext_src_dir, filename)
|
118
|
+
|
119
|
+
puts "fetching #{remote_file} to #{local_file}"
|
120
|
+
open(remote_file, 'rb') do |rf|
|
121
|
+
content = rf.read
|
122
|
+
File.open(local_file, 'wb') { |f| f.puts content }
|
123
|
+
end
|
119
124
|
end
|
120
|
-
end
|
121
125
|
|
122
|
-
|
123
|
-
|
124
|
-
|
126
|
+
FileUtils.cd(ext_src_dir) do
|
127
|
+
system('swig -c++ -ruby -module oboe_metal oboe.i')
|
128
|
+
FileUtils.rm('oboe.i')
|
129
|
+
end
|
125
130
|
end
|
126
|
-
|
131
|
+
|
132
|
+
task :fetch => :fetch_ext_deps
|
127
133
|
|
128
134
|
desc "Build the gem's c extension"
|
129
135
|
task :compile do
|
@@ -136,7 +142,7 @@ task :compile do
|
|
136
142
|
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
|
137
143
|
|
138
144
|
Dir.chdir ext_dir
|
139
|
-
ENV['APPOPTICS_FROM_S3'] = 'true'
|
145
|
+
# ENV['APPOPTICS_FROM_S3'] = 'true'
|
140
146
|
cmd = [Gem.ruby, 'extconf.rb']
|
141
147
|
sh cmd.join(' ')
|
142
148
|
sh '/usr/bin/env make'
|
@@ -174,6 +180,7 @@ task :clean do
|
|
174
180
|
Dir.chdir ext_dir
|
175
181
|
sh '/usr/bin/env make clean' if File.exist? 'Makefile'
|
176
182
|
|
183
|
+
FileUtils.rm_f "src/oboe_wrap.cxx"
|
177
184
|
Dir.chdir pwd
|
178
185
|
else
|
179
186
|
puts '== Nothing to do under JRuby.'
|
data/appoptics_apm.gemspec
CHANGED
@@ -54,6 +54,6 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
|
|
54
54
|
s.add_development_dependency('benchmark-ips', '>= 2.7.2')
|
55
55
|
end
|
56
56
|
|
57
|
-
s.required_ruby_version = '>= 2.
|
57
|
+
s.required_ruby_version = '>= 2.4.0'
|
58
58
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
59
59
|
end
|
@@ -8,13 +8,8 @@ else
|
|
8
8
|
./build_gem.sh
|
9
9
|
fi
|
10
10
|
|
11
|
-
|
12
|
-
current_ruby=`rbenv global`
|
13
|
-
rbenv global 2.4.1
|
11
|
+
gem install package_cloud --no-document
|
14
12
|
|
15
13
|
# prerequisite: package_cloud token needs to be in ~/.packagecloud
|
16
14
|
gem=`ls -dt1 appoptics_apm-[^pre]*.gem | head -1`
|
17
15
|
package_cloud push solarwinds/appoptics-apm-ruby $gem
|
18
|
-
|
19
|
-
# restore ruby version
|
20
|
-
rbenv global $current_ruby
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Debug the c-code with gdb
|
2
|
+
|
3
|
+
inspired by: https://dev.to/wataash/how-to-create-and-debug-ruby-gem-with-c-native-extension-3l8b
|
4
|
+
|
5
|
+
|
6
|
+
## install ruby with sources
|
7
|
+
|
8
|
+
rbenv is your friend ;) 😄 -k means keep sources
|
9
|
+
|
10
|
+
```
|
11
|
+
rbenv install -k 2.6.3
|
12
|
+
rbenv shell 2.6.3
|
13
|
+
|
14
|
+
# check that ruby is debuggable
|
15
|
+
type ruby # => ruby is /home/wsh/.rbenv/shims/ruby
|
16
|
+
rbenv which ruby # => /home/wsh/.rbenv/versions/2.6.3/bin/ruby
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
##
|
21
|
+
## add debug info when compiling appoptics_apm
|
22
|
+
add this line to extconf.rb to turn off optimization
|
23
|
+
|
24
|
+
```
|
25
|
+
CONFIG["optflags"] = "-O0"
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
##
|
30
|
+
## start ruby app with gdb
|
31
|
+
|
32
|
+
This will run ruby and load the app with a breakpoint in the Reporter::startThread
|
33
|
+
c-function.
|
34
|
+
|
35
|
+
`bundle exec gdb -q -ex 'set breakpoint pending on' -ex 'b Reporter::startThread' -ex run --args ruby -e 'require "./app"'`
|
36
|
+
|
37
|
+
If there is a bug in the ruby code or a ruby byebug binding that halts the
|
38
|
+
script, the debugger will hang without showing any output.
|
39
|
+
So, make sure `bundle exec ruby app.rb` runs.
|
40
|
+
|
41
|
+
use the gdb navigation commands to step through the code. If it says:
|
42
|
+
|
43
|
+
```
|
44
|
+
(gdb) n
|
45
|
+
Single stepping until exit from function _ZN8Reporter11startThreadEv@plt,
|
46
|
+
which has no line number information.
|
47
|
+
```
|
48
|
+
|
49
|
+
type `c` and it may end up stopping in the right location.
|
50
|
+
|
51
|
+
##
|
52
|
+
## make ruby .gdbinit macros available
|
53
|
+
|
54
|
+
These macros are pretty elaborate. They are checked in the ruby github
|
55
|
+
repo: https://github.com/ruby/ruby/blob/master/.gdbinit
|
56
|
+
The code is nicely formatted and colorized in github and easiest to read there.
|
57
|
+
|
58
|
+
installation in the user's home dir:
|
59
|
+
```
|
60
|
+
wget https://github.com/ruby/ruby/blob/master/.gdbinit
|
61
|
+
```
|
62
|
+
##
|
63
|
+
## examples
|
64
|
+
|
65
|
+
Some inspiring examples here:
|
66
|
+
|
67
|
+
https://jvns.ca/blog/2016/06/12/a-weird-system-call-process-vm-readv/
|
68
|
+
|
69
|
+
https://medium.com/@zanker/finding-a-ruby-bug-with-gdb-56d6b321bc86
|
data/ext/oboe_metal/src/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.0
|
data/ext/oboe_metal/src/oboe.h
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
/**
|
2
2
|
* @file oboe.h
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* API header for AppOptics' Oboe application tracing library for use with AppOptics.
|
5
5
|
*
|
6
6
|
* @package Oboe
|
7
7
|
* @author AppOptics
|
8
8
|
* @copyright Copyright (c) 2016, SolarWinds LLC
|
9
|
-
* @license
|
9
|
+
* @license
|
10
10
|
* @link https://appoptics.com
|
11
11
|
**/
|
12
12
|
|
@@ -81,6 +81,10 @@ extern "C" {
|
|
81
81
|
* Default events flush batch size in KB.
|
82
82
|
*/
|
83
83
|
#define OBOE_DEFAULT_EVENTS_FLUSH_BATCH_SIZE 2000
|
84
|
+
/**
|
85
|
+
* Default EC2 metadata timeout in milliseconds
|
86
|
+
*/
|
87
|
+
#define OBOE_DEFAULT_EC2_METADATA_TIMEOUT 1000
|
84
88
|
|
85
89
|
#define OBOE_SAMPLE_RESOLUTION 1000000
|
86
90
|
|
@@ -167,6 +171,8 @@ typedef struct oboe_init_options {
|
|
167
171
|
int token_bucket_capacity; // custom token bucket capacity
|
168
172
|
int token_bucket_rate; // custom token bucket rate
|
169
173
|
int file_single; // use single files in file reporter for each event
|
174
|
+
|
175
|
+
int ec2_metadata_timeout; // EC2 metadata timeout in milliseconds
|
170
176
|
} oboe_init_options_t;
|
171
177
|
|
172
178
|
typedef struct oboe_span_params {
|
@@ -183,12 +189,22 @@ typedef struct oboe_span_params {
|
|
183
189
|
int do_metrics; // boolean flag whether a (HTTP) span should be sent (1) or not (0)
|
184
190
|
} oboe_span_params_t;
|
185
191
|
|
192
|
+
//
|
193
|
+
// oboe_get_tracing_decisions input and output structures
|
194
|
+
//
|
186
195
|
typedef struct oboe_tracing_decisions_in {
|
187
|
-
int version;
|
188
|
-
const char *service_name;
|
189
|
-
const char *in_xtrace;
|
190
|
-
int custom_sample_rate;
|
191
|
-
int custom_tracing_mode;
|
196
|
+
int version; // the version of this structure
|
197
|
+
const char *service_name; // custom service name
|
198
|
+
const char *in_xtrace; // existing X-Trace from passed in HTTP header
|
199
|
+
int custom_sample_rate; // custom sample rate
|
200
|
+
int custom_tracing_mode; // custom tracing mode
|
201
|
+
|
202
|
+
// v2
|
203
|
+
int custom_trigger_mode; // custom trigger mode
|
204
|
+
int request_type; // the request type: OBOE_REQUEST_TYPE_REGULAR, OBOE_REQUEST_TYPE_TRIGGER
|
205
|
+
const char *header_options; // X-Trace-Options HTTP header value
|
206
|
+
const char *header_signature; // X-Trace-Options-Signature HTTP header value
|
207
|
+
time_t header_timestamp; // timestamp from X-Trace-Options header, converted to UNIX timestamp format
|
192
208
|
} oboe_tracing_decisions_in_t;
|
193
209
|
|
194
210
|
typedef struct oboe_tracing_decisions_out {
|
@@ -197,6 +213,12 @@ typedef struct oboe_tracing_decisions_out {
|
|
197
213
|
int sample_source;
|
198
214
|
int do_sample;
|
199
215
|
int do_metrics;
|
216
|
+
|
217
|
+
// v2
|
218
|
+
int request_provisioned;
|
219
|
+
int auth_status;
|
220
|
+
const char *auth_message;
|
221
|
+
const char *status_message;
|
200
222
|
} oboe_tracing_decisions_out_t;
|
201
223
|
|
202
224
|
typedef struct oboe_internal_stats {
|
@@ -357,7 +379,7 @@ int oboe_init(oboe_init_options_t* options);
|
|
357
379
|
* Initialize the Oboe subsytems using a specific reporter configuration.
|
358
380
|
*
|
359
381
|
* This should be called before any other oboe_* functions butm may also be
|
360
|
-
* used to change or re-initialize the current reporter. To reconnect the
|
382
|
+
* used to change or re-initialize the current reporter. To reconnect the
|
361
383
|
* reporter use oboe_disconnect() and oboe_reconnect() instead.
|
362
384
|
*
|
363
385
|
* @param protocol One of OBOE_REPORTER_PROTOCOL_FILE, OBOE_REPORTER_PROTOCOL_UDP,
|
@@ -367,7 +389,12 @@ int oboe_init(oboe_init_options_t* options);
|
|
367
389
|
*/
|
368
390
|
int oboe_init_reporter(const char *protocol, oboe_init_options_t *options);
|
369
391
|
|
370
|
-
|
392
|
+
/**
|
393
|
+
* returns one of these:
|
394
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_OK
|
395
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION
|
396
|
+
*/
|
397
|
+
int oboe_init_options_set_defaults(oboe_init_options_t *options);
|
371
398
|
|
372
399
|
/**
|
373
400
|
* Disconnect or shut down the Oboe reporter, but allow it to be reconnect()ed.
|
@@ -429,6 +456,7 @@ void oboe_shutdown();
|
|
429
456
|
#define OBOE_SETTINGS_FLAG_SAMPLE_START 0x4
|
430
457
|
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH 0x8
|
431
458
|
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH_ALWAYS 0x10
|
459
|
+
#define OBOE_SETTINGS_FLAG_TRIGGERED_TRACE 0x20
|
432
460
|
#define OBOE_SETTINGS_MAX_STRLEN 256
|
433
461
|
|
434
462
|
#define OBOE_SETTINGS_UNSET -1
|
@@ -455,9 +483,6 @@ void oboe_shutdown();
|
|
455
483
|
#pragma pack(push, 1)
|
456
484
|
#endif
|
457
485
|
|
458
|
-
#define TOKEN_BUCKET_CAPACITY_DEFAULT 16 // bucket capacity (how many tokens fit into the bucket)
|
459
|
-
#define TOKEN_BUCKET_RATE_PER_SECOND_DEFAULT 8 // rate per second (number of tokens per second)
|
460
|
-
|
461
486
|
#define OBOE_SEND_EVENT 0
|
462
487
|
#define OBOE_SEND_STATUS 1
|
463
488
|
#define OBOE_SEND_PROFILING 2
|
@@ -477,7 +502,17 @@ void oboe_shutdown();
|
|
477
502
|
#define OBOE_SPAN_NO_REPORTER -4
|
478
503
|
#define OBOE_SPAN_NOT_READY -5
|
479
504
|
|
480
|
-
// these codes are
|
505
|
+
// these codes are returned by oboe_sample_layer_custom(), oboe_tracing_decisions(),
|
506
|
+
// oboe_reporter_is_ready(), and referenced in settings_messages.c (to convert
|
507
|
+
// error codes to messages.)
|
508
|
+
//
|
509
|
+
// they are structured such that codes that are <= 0 are successful, i.e., no
|
510
|
+
// error status needs to be reported to the user, while codes > 0 are errors that
|
511
|
+
// need to be reported.
|
512
|
+
|
513
|
+
#define OBOE_TRACING_DECISIONS_FAILED_AUTH -5
|
514
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_EXHAUSTED -4
|
515
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_DISABLED -3
|
481
516
|
#define OBOE_TRACING_DECISIONS_TRACING_DISABLED -2
|
482
517
|
#define OBOE_TRACING_DECISIONS_XTRACE_NOT_SAMPLED -1
|
483
518
|
#define OBOE_TRACING_DECISIONS_OK 0
|
@@ -486,8 +521,31 @@ void oboe_shutdown();
|
|
486
521
|
#define OBOE_TRACING_DECISIONS_REPORTER_NOT_READY 3
|
487
522
|
#define OBOE_TRACING_DECISIONS_NO_VALID_SETTINGS 4
|
488
523
|
#define OBOE_TRACING_DECISIONS_QUEUE_FULL 5
|
524
|
+
#define OBOE_TRACING_DECISIONS_BAD_ARG 6
|
525
|
+
|
526
|
+
// convert above codes into const char* messages.
|
527
|
+
const char* oboe_get_tracing_decisions_message(int code);
|
528
|
+
|
529
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_CHECKED -2
|
530
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_PRESENT -1
|
531
|
+
#define OBOE_TRACING_DECISIONS_AUTH_OK 0
|
532
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NO_SIG_KEY 1
|
533
|
+
#define OBOE_TRACING_DECISIONS_AUTH_INVALID_SIG 2
|
534
|
+
#define OBOE_TRACING_DECISIONS_AUTH_BAD_TIMESTAMP 3
|
489
535
|
|
490
|
-
//
|
536
|
+
// convert above codes into const char* messages.
|
537
|
+
const char* oboe_get_tracing_decisions_auth_message (int code);
|
538
|
+
|
539
|
+
#define OBOE_REQUEST_TYPE_NONE -1
|
540
|
+
#define OBOE_REQUEST_TYPE_REGULAR 0
|
541
|
+
#define OBOE_REQUEST_TYPE_TRIGGER 1
|
542
|
+
|
543
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_OK 0
|
544
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION 1
|
545
|
+
|
546
|
+
//
|
547
|
+
// these codes are returned by oboe_init(), oboe_init_reporter(), _oboe_create_reporter()
|
548
|
+
//
|
491
549
|
#define OBOE_INIT_ALREADY_INIT -1
|
492
550
|
#define OBOE_INIT_OK 0
|
493
551
|
#define OBOE_INIT_WRONG_VERSION 1
|
@@ -501,6 +559,17 @@ void oboe_shutdown();
|
|
501
559
|
#define OBOE_INIT_SSL_LOAD_CERT 9
|
502
560
|
#define OBOE_INIT_SSL_REPORTER_CREATE 10
|
503
561
|
|
562
|
+
// token buckets
|
563
|
+
enum TOKEN_BUCKETS {
|
564
|
+
TOKEN_BUCKET_SAMPLING, // for normal requests
|
565
|
+
TOKEN_BUCKET_TT_RELAXED, // for triggered traces initiated by Pingdom and
|
566
|
+
// other trusted sources (relaxed settings)
|
567
|
+
TOKEN_BUCKET_TT_STRICT, // for triggered traces initiated by CLI and
|
568
|
+
// other untrusted sources (strict settings)
|
569
|
+
TOKEN_BUCKET_COUNT // IMPORTANT NOTE: this must be the last element
|
570
|
+
// inside the enum
|
571
|
+
};
|
572
|
+
|
504
573
|
typedef struct {
|
505
574
|
uint32_t magic;
|
506
575
|
uint32_t timestamp;
|
@@ -510,8 +579,9 @@ typedef struct {
|
|
510
579
|
uint32_t ttl;
|
511
580
|
uint32_t _pad;
|
512
581
|
char layer[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
513
|
-
double bucket_capacity;
|
514
|
-
double bucket_rate_per_sec;
|
582
|
+
double bucket_capacity[TOKEN_BUCKET_COUNT];
|
583
|
+
double bucket_rate_per_sec[TOKEN_BUCKET_COUNT];
|
584
|
+
char signature_key[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
515
585
|
} oboe_settings_t;
|
516
586
|
|
517
587
|
typedef struct {
|
@@ -531,6 +601,7 @@ typedef struct {
|
|
531
601
|
volatile uint32_t through_count; // # of through traces
|
532
602
|
volatile uint32_t through_ignored_count; // # of new requests, that are rejected due to start_always_flag == 0
|
533
603
|
// that have through_always_flag == 1
|
604
|
+
volatile uint32_t triggered_count; // # of triggered traces
|
534
605
|
volatile uint32_t last_used_sample_rate;
|
535
606
|
volatile uint32_t last_used_sample_source;
|
536
607
|
|
@@ -541,12 +612,13 @@ typedef struct {
|
|
541
612
|
typedef struct {
|
542
613
|
int tracing_mode; // pushed from server, override from config file
|
543
614
|
int sample_rate; // pushed from server, override from config file
|
615
|
+
int trigger_mode; // pushed from server, override from config file
|
544
616
|
oboe_settings_t *settings; // cached settings, updated by tracelyzer (init to NULL)
|
545
|
-
int last_auto_sample_rate; // stores last known automatic sampling rate
|
546
|
-
uint16_t last_auto_flags; // stores last known flags associated with above
|
617
|
+
int last_auto_sample_rate; // stores last known automatic sampling rate
|
618
|
+
uint16_t last_auto_flags; // stores last known flags associated with above
|
547
619
|
uint32_t last_auto_timestamp; // timestamp from last *settings lookup
|
548
620
|
uint32_t last_refresh; // last refresh time
|
549
|
-
token_bucket_t bucket;
|
621
|
+
token_bucket_t bucket[TOKEN_BUCKET_COUNT]; // token buckets for various tasks
|
550
622
|
} oboe_settings_cfg_t;
|
551
623
|
|
552
624
|
int oboe_settings_init_local();
|
@@ -560,9 +632,10 @@ entry_layer_t* oboe_settings_entry_layer_get(const char* name);
|
|
560
632
|
oboe_settings_cfg_t* oboe_settings_cfg_get();
|
561
633
|
void oboe_settings_cfg_init(oboe_settings_cfg_t *cfg);
|
562
634
|
|
563
|
-
void oboe_settings_set(int sample_rate, int tracing_mode);
|
635
|
+
void oboe_settings_set(int sample_rate, int tracing_mode, int trigger_mode);
|
564
636
|
void oboe_settings_rate_set(int sample_rate);
|
565
637
|
void oboe_settings_mode_set(int tracing_mode);
|
638
|
+
void oboe_settings_trigger_set(int trigger_mode);
|
566
639
|
|
567
640
|
int oboe_rand_get_value();
|
568
641
|
|
@@ -588,49 +661,7 @@ int oboe_sample_is_enabled(oboe_settings_cfg_t *cfg);
|
|
588
661
|
* headers, and, if appropriate, rolls the virtual dice to
|
589
662
|
* decide if this request should be sampled.
|
590
663
|
*
|
591
|
-
* This is designed to be called once per
|
592
|
-
*
|
593
|
-
* @param service_name Service name used for this request (may be NULL to use default settings)
|
594
|
-
* @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
|
595
|
-
* @param sample_rate_out The sample rate used to check if this request should be sampled
|
596
|
-
* (output - may be zero if not used).
|
597
|
-
* @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
|
598
|
-
* should be sampled (output - may be zero if not used).
|
599
|
-
* @return Non-zero if the given request should be sampled.
|
600
|
-
*/
|
601
|
-
int oboe_sample_layer(
|
602
|
-
const char *service_name,
|
603
|
-
const char *xtrace,
|
604
|
-
int *sample_rate_out,
|
605
|
-
int *sample_source_out
|
606
|
-
);
|
607
|
-
|
608
|
-
/**
|
609
|
-
* Same as oboe_sample_layer() but accepting custom sample rate and custom tracing mode
|
610
|
-
*
|
611
|
-
* @param service_name Service name used for this request (may be NULL to use default settings)
|
612
|
-
* @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
|
613
|
-
* @param custom_sample_rate a custom sample rate only used for this request (OBOE_SETTINGS_UNSET won't override)
|
614
|
-
* @param custom_tracing_mode a custom tracing mode only used for this request (OBOE_SETTINGS_UNSET won't override)
|
615
|
-
* @param sample_rate_out The sample rate used to check if this request should be sampled
|
616
|
-
* (output - may be zero if not used).
|
617
|
-
* @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
|
618
|
-
* should be sampled (output - may be zero if not used).
|
619
|
-
* @param flags_out The flags used to check if this request should be sampled
|
620
|
-
*/
|
621
|
-
int oboe_sample_layer_custom(
|
622
|
-
const char *service_name,
|
623
|
-
const char *in_xtrace,
|
624
|
-
int custom_sample_rate,
|
625
|
-
int custom_tracing_mode,
|
626
|
-
int *sampling_decision_out,
|
627
|
-
int *sample_rate_out,
|
628
|
-
int *sample_source_out,
|
629
|
-
uint16_t *flags_out
|
630
|
-
);
|
631
|
-
|
632
|
-
/**
|
633
|
-
* wrapper for calling oboe_sample_layer_custom() with input/output structs instead of individual params
|
664
|
+
* This is designed to be called once per request.
|
634
665
|
*
|
635
666
|
* @param in Struct containing all params to help making a tracing decision
|
636
667
|
* @param out Struct containing all params that get set during decision making
|
@@ -773,21 +804,21 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
773
804
|
* We use this to get a reasonable standard format between apps.
|
774
805
|
*
|
775
806
|
* @param module An OBOE_MODULE_* module identifier. Use zero for undefined.
|
776
|
-
* @param app_name Either NULL or a pointer to a string containing a name for
|
777
|
-
* the application - will prefix the log entry. Useful when multiple
|
778
|
-
* apps log to the same destination.
|
807
|
+
* @param app_name Either NULL or a pointer to a string containing a name for
|
808
|
+
* the application - will prefix the log entry. Useful when multiple
|
809
|
+
* apps log to the same destination.
|
779
810
|
* @param trace_mode A string identifying the configured tracing mode, one of:
|
780
811
|
* "enabled", "disabled", "unset", or "undef" (for invalid values)
|
781
812
|
* Use the oboe_tracing_mode_to_string() function to convert from
|
782
813
|
* numeric values.
|
783
814
|
* @param sample_rate The configured sampling rate: -1 for unset or a
|
784
815
|
* integer fraction of 1000000.
|
785
|
-
* @param reporter_type String identifying the type of reporter configured:
|
816
|
+
* @param reporter_type String identifying the type of reporter configured:
|
786
817
|
* One of 'udp' (the default), 'ssl', or 'file'.
|
787
818
|
* @param reporter_args The string of comma-separated key=value settings
|
788
819
|
* used to initialize the reporter.
|
789
820
|
* @param extra: Either NULL or a pointer to a string to be appended to
|
790
|
-
* the log message and designed to include a few other
|
821
|
+
* the log message and designed to include a few other
|
791
822
|
* configuration parameters of interest.
|
792
823
|
*/
|
793
824
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|
@@ -821,7 +852,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
821
852
|
/**
|
822
853
|
* Log a recoverable error.
|
823
854
|
*
|
824
|
-
* Each message is limited in the number of times that it will be reported at the
|
855
|
+
* Each message is limited in the number of times that it will be reported at the
|
825
856
|
* ERROR level after which it will be logged at the debug MEDIUM level.
|
826
857
|
*/
|
827
858
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_ERROR
|
@@ -838,7 +869,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
838
869
|
/**
|
839
870
|
* Log a warning.
|
840
871
|
*
|
841
|
-
* Each message is limited in the number of times that it will be reported at the
|
872
|
+
* Each message is limited in the number of times that it will be reported at the
|
842
873
|
* WARNING level after which it will be logged at the debug MEDIUM level.
|
843
874
|
*/
|
844
875
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_WARNING
|
@@ -855,7 +886,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
855
886
|
/**
|
856
887
|
* Log an informative message.
|
857
888
|
*
|
858
|
-
* Each message is limited in the number of times that it will be reported at the
|
889
|
+
* Each message is limited in the number of times that it will be reported at the
|
859
890
|
* INFO level after which it will be logged at the debug MEDIUM level.
|
860
891
|
*/
|
861
892
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|