appoptics_apm 4.7.0 → 4.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +37 -23
- data/.yardopts +1 -0
- data/README.md +2 -2
- data/Rakefile +11 -5
- 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/lib/appoptics_apm.rb +17 -17
- data/lib/appoptics_apm/base.rb +1 -4
- data/lib/appoptics_apm/config.rb +15 -18
- 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/sidekiq-worker.rb +2 -1
- data/lib/appoptics_apm/oboe_init_options.rb +183 -0
- data/lib/appoptics_apm/support/transaction_settings.rb +11 -3
- data/lib/appoptics_apm/version.rb +3 -3
- data/lib/oboe_metal.rb +49 -75
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37478c40a16c8636f4589a15e63db8d1b2eb0eae
|
4
|
+
data.tar.gz: 2f2ac3b316e00963c42593680e638ecfc1792e3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f695fc74e9f23d799709c32faab13b8c8c56e2f7da34b6968a5f085daf964927d3c98ffcadc49be6ab181fb66a872a4ec97d121468f01ed205c449e0d0873abc
|
7
|
+
data.tar.gz: 730addb2cda57f6555d4965656cfeb1e753e32e7886e13cc1714c8b97b094664c4d0702a5494dc49ea7c266de6c101b25c4927a82ed652822890a581e45550b0
|
data/.travis.yml
CHANGED
@@ -11,10 +11,9 @@ 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
|
-
- 2.3.8
|
18
17
|
- ruby-head
|
19
18
|
# - jruby-9.0.5.0
|
20
19
|
|
@@ -24,6 +23,7 @@ gemfile:
|
|
24
23
|
- gemfiles/instrumentation_mocked.gemfile
|
25
24
|
- gemfiles/instrumentation_mocked_oldgems.gemfile
|
26
25
|
- gemfiles/frameworks.gemfile
|
26
|
+
- gemfiles/rails60.gemfile
|
27
27
|
- gemfiles/rails52.gemfile
|
28
28
|
- gemfiles/rails42.gemfile
|
29
29
|
- gemfiles/delayed_job.gemfile
|
@@ -33,13 +33,14 @@ matrix:
|
|
33
33
|
exclude:
|
34
34
|
- rvm: ruby-head
|
35
35
|
gemfile: gemfiles/rails42.gemfile
|
36
|
-
- rvm: 2.6.
|
36
|
+
- rvm: 2.6.4
|
37
37
|
gemfile: gemfiles/rails42.gemfile
|
38
|
+
- rvm: 2.4.5
|
39
|
+
gemfile: gemfiles/rails60.gemfile
|
38
40
|
|
39
|
-
|
40
|
-
- rmv: 2.6.2
|
41
|
+
- rmv: 2.6.4
|
41
42
|
env: DBTYPE=mysql
|
42
|
-
- rvm: 2.5.
|
43
|
+
- rvm: 2.5.5
|
43
44
|
env: DBTYPE=mysql
|
44
45
|
- rvm: 2.4.5
|
45
46
|
env: DBTYPE=mysql
|
@@ -58,10 +59,10 @@ matrix:
|
|
58
59
|
env: DBTYPE=mysql
|
59
60
|
- gemfile: gemfiles/frameworks.gemfile
|
60
61
|
env: DBTYPE=mysql
|
61
|
-
- gemfile: gemfiles/rails51.gemfile
|
62
|
-
env: DBTYPE=mysql
|
63
62
|
- gemfile: gemfiles/rails52.gemfile
|
64
63
|
env: DBTYPE=mysql
|
64
|
+
- gemfile: gemfiles/rails60.gemfile
|
65
|
+
env: DBTYPE=mysql
|
65
66
|
- gemfile: gemfiles/delayed_job.gemfile
|
66
67
|
env: DBTYPE=mysql
|
67
68
|
|
@@ -86,12 +87,15 @@ matrix:
|
|
86
87
|
# Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484
|
87
88
|
# Updated Cassandra: https://github.com/travis-ci/travis-ci/issues/1650
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
-
|
94
|
-
- 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
|
95
99
|
|
96
100
|
install:
|
97
101
|
- curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.8/swig-3.0.8.tar.gz
|
@@ -101,22 +105,32 @@ install:
|
|
101
105
|
- popd
|
102
106
|
|
103
107
|
before_script:
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
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
|
+
- export OBOE_VERSION=5.1.1
|
115
|
+
- bundle --jobs=3 --retry=3
|
116
|
+
- bundle exec rake clean fetch compile
|
108
117
|
- psql -c 'create database travis_ci_test;' -U postgres
|
109
118
|
- mysql -e 'create database travis_ci_test;'
|
110
119
|
- redis-server --requirepass secret_pass &
|
111
120
|
- sleep 10
|
112
|
-
- export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
|
113
|
-
- export APPOPTICS_TOKEN_BUCKET_RATE=1000
|
114
121
|
|
115
122
|
script: "N=1 bundle exec rake test"
|
116
123
|
|
117
124
|
services:
|
118
125
|
- mongodb
|
119
126
|
- memcached
|
120
|
-
-
|
121
|
-
# -
|
127
|
+
- mysql
|
128
|
+
# - cassandra
|
129
|
+
- postgresql
|
130
|
+
# - redis-server
|
122
131
|
- rabbitmq
|
132
|
+
|
133
|
+
addons:
|
134
|
+
apt:
|
135
|
+
packages:
|
136
|
+
- rabbitmq-server
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
The appoptics_apm gem provides [AppOptics APM](https://www.appoptics.com/) performance instrumentation for Ruby.
|
4
4
|
|
5
|
-
![Ruby AppOpticsAPM](https://docs.appoptics.com/_images/
|
5
|
+
![Ruby AppOpticsAPM](https://docs.appoptics.com/_images/ruby_trace_smaller.png)
|
6
6
|
|
7
7
|
It has the ability to report performance metrics on an array of libraries, databases and frameworks such as Rails,
|
8
8
|
Mongo, Memcache, ActiveRecord, Cassandra, Rack, Resque
|
@@ -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
|
@@ -63,13 +66,13 @@ end
|
|
63
66
|
desc "Run all test suites defined by travis"
|
64
67
|
task "docker_tests" do
|
65
68
|
Dir.chdir('test/run_tests')
|
66
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
69
|
+
exec('docker-compose run --rm ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test --remove-orphans')
|
67
70
|
end
|
68
71
|
|
69
72
|
desc "Start docker container for testing and debugging"
|
70
73
|
task "docker" do
|
71
74
|
Dir.chdir('test/run_tests')
|
72
|
-
exec('docker-compose run ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
75
|
+
exec('docker-compose run --rm ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash --remove-orphans')
|
73
76
|
end
|
74
77
|
|
75
78
|
desc "Stop all containers that were started for testing and debugging"
|
@@ -81,11 +84,11 @@ end
|
|
81
84
|
desc "Fetch extension dependency files"
|
82
85
|
task :fetch_ext_deps do
|
83
86
|
swig_version = %x{swig -version} rescue ''
|
84
|
-
swig_version = swig_version.scan(/swig version
|
87
|
+
swig_version = swig_version.scan(/swig version [34]/i)
|
85
88
|
if swig_version.empty?
|
86
89
|
$stderr.puts '== ERROR ================================================================='
|
87
|
-
$stderr.puts "Could not find required swig version 3.0
|
88
|
-
$stderr.puts 'Please install swig "
|
90
|
+
$stderr.puts "Could not find required swig version >= 3.0.8, found #{swig_version.inspect}"
|
91
|
+
$stderr.puts 'Please install swig ">= 3.0.8" and try again.'
|
89
92
|
$stderr.puts '=========================================================================='
|
90
93
|
raise
|
91
94
|
end
|
@@ -108,6 +111,7 @@ task :fetch_ext_deps do
|
|
108
111
|
# oboe and bson header files
|
109
112
|
FileUtils.mkdir_p(File.join(ext_src_dir, 'bson'))
|
110
113
|
%w(oboe.h oboe.hpp oboe_debug.h oboe.i bson/bson.h bson/platform_hacks.h).each do |filename|
|
114
|
+
# %w(oboe.h oboe_debug.h bson/bson.h bson/platform_hacks.h).each do |filename|
|
111
115
|
remote_file = File.join(oboe_s3_dir, 'include', filename)
|
112
116
|
local_file = File.join(ext_src_dir, filename)
|
113
117
|
|
@@ -124,6 +128,8 @@ task :fetch_ext_deps do
|
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
131
|
+
task :fetch => :fetch_ext_deps
|
132
|
+
|
127
133
|
desc "Build the gem's c extension"
|
128
134
|
task :compile do
|
129
135
|
if !defined?(JRUBY_VERSION)
|
@@ -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
|
+
5.1.1
|
data/lib/appoptics_apm.rb
CHANGED
@@ -21,22 +21,23 @@ begin
|
|
21
21
|
require 'joboe_metal'
|
22
22
|
elsif RUBY_PLATFORM =~ /linux/
|
23
23
|
require_relative './oboe_metal.so'
|
24
|
+
require 'appoptics_apm/oboe_init_options'
|
24
25
|
require 'oboe_metal.rb' # sets AppOpticsAPM.loaded = true if successful
|
25
26
|
else
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
AppOpticsAPM.logger.warn '==================================================================='
|
28
|
+
AppOpticsAPM.logger.warn "AppOptics warning: Platform #{RUBY_PLATFORM} not yet supported."
|
29
|
+
AppOpticsAPM.logger.warn 'see: https://docs.appoptics.com/kb/apm_tracing/supported_platforms/'
|
30
|
+
AppOpticsAPM.logger.warn 'Tracing disabled.'
|
31
|
+
AppOpticsAPM.logger.warn 'Contact support@appoptics.com if this is unexpected.'
|
32
|
+
AppOpticsAPM.logger.warn '==================================================================='
|
32
33
|
end
|
33
34
|
rescue LoadError => e
|
34
35
|
unless ENV['RAILS_GROUP'] == 'assets' or ENV['IGNORE_APPOPTICS_WARNING']
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
AppOpticsAPM.logger.error '=============================================================='
|
37
|
+
AppOpticsAPM.logger.error 'Missing AppOpticsAPM libraries. Tracing disabled.'
|
38
|
+
AppOpticsAPM.logger.error "Error: #{e.message}"
|
39
|
+
AppOpticsAPM.logger.error 'See: https://docs.appoptics.com/kb/apm_tracing/ruby/'
|
40
|
+
AppOpticsAPM.logger.error '=============================================================='
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -46,8 +47,6 @@ begin
|
|
46
47
|
require 'appoptics_apm/method_profiling'
|
47
48
|
|
48
49
|
if AppOpticsAPM.loaded
|
49
|
-
# tracing mode is configured via config file but can only be set once we have oboe_metal loaded
|
50
|
-
AppOpticsAPM.set_tracing_mode(AppOpticsAPM::Config[:tracing_mode].to_sym)
|
51
50
|
require 'appoptics_apm/instrumentation'
|
52
51
|
require 'appoptics_apm/support/transaction_metrics'
|
53
52
|
|
@@ -57,10 +56,11 @@ begin
|
|
57
56
|
require 'appoptics_apm/frameworks/padrino'
|
58
57
|
require 'appoptics_apm/frameworks/grape'
|
59
58
|
else
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
AppOpticsAPM.logger.warn '=============================================================='
|
60
|
+
AppOpticsAPM.logger.warn 'AppOpticsAPM not loaded. Tracing disabled.'
|
61
|
+
AppOpticsAPM.logger.warn 'There may be a problem with the service key or other settings.'
|
62
|
+
AppOpticsAPM.logger.warn 'Please check previous log messages.'
|
63
|
+
AppOpticsAPM.logger.warn '=============================================================='
|
64
64
|
require 'appoptics_apm/noop/context'
|
65
65
|
require 'appoptics_apm/noop/metadata'
|
66
66
|
end
|
data/lib/appoptics_apm/base.rb
CHANGED
@@ -21,13 +21,10 @@ SAMPLE_SOURCE_MASK = 0b1111000000000000000000000000
|
|
21
21
|
# ZERO_SAMPLE_RATE_MASK = 0b1111000000000000000000000000
|
22
22
|
# ZERO_SAMPLE_SOURCE_MASK = 0b0000111111111111111111111111
|
23
23
|
|
24
|
-
APPOPTICS_STR_BLANK = ''.freeze
|
24
|
+
# APPOPTICS_STR_BLANK = ''.freeze
|
25
25
|
APPOPTICS_STR_LAYER = 'Layer'.freeze
|
26
26
|
APPOPTICS_STR_LABEL = 'Label'.freeze
|
27
27
|
|
28
|
-
# Used in tests to store local trace data
|
29
|
-
TRACE_FILE = '/tmp/appoptics_traces.bson'.freeze
|
30
|
-
|
31
28
|
##
|
32
29
|
# This module is the base module for the various implementations of AppOpticsAPM reporting.
|
33
30
|
# Current variations as of 2014-09-10 are a c-extension, JRuby (using AppOpticsAPM Java
|
data/lib/appoptics_apm/config.rb
CHANGED
@@ -67,19 +67,22 @@ module AppOpticsAPM
|
|
67
67
|
].join(' ')
|
68
68
|
end
|
69
69
|
load(config_files[0])
|
70
|
-
|
70
|
+
# sets AppOpticsAPM::Config[:debug_level], AppOpticsAPM.logger.level
|
71
|
+
set_log_level
|
72
|
+
|
73
|
+
# the verbose setting is only relevant for ruby, ENV['APPOPTICS_GEM_VERBOSE'] overrides
|
74
|
+
if ENV.key?('APPOPTICS_GEM_VERBOSE')
|
75
|
+
AppOpticsAPM::Config[:verbose] = ENV['APPOPTICS_GEM_VERBOSE'].downcase == 'true'
|
76
|
+
end
|
71
77
|
end
|
72
78
|
|
73
|
-
|
74
|
-
# Oboe will override vars passed in if it finds an environment variable
|
75
|
-
# :debug_level and :verbose need special consideration, because they are used in Ruby
|
76
|
-
def self.check_env_vars
|
79
|
+
def self.set_log_level
|
77
80
|
unless (-1..6).include?(AppOpticsAPM::Config[:debug_level])
|
78
81
|
AppOpticsAPM::Config[:debug_level] = 3
|
79
82
|
end
|
80
83
|
|
81
|
-
# let's find and use the
|
82
|
-
debug_level = ENV['APPOPTICS_DEBUG_LEVEL']
|
84
|
+
# let's find and use the equivalent debug level for ruby
|
85
|
+
debug_level = (ENV['APPOPTICS_DEBUG_LEVEL'] || AppOpticsAPM::Config[:debug_level] || 3).to_i
|
83
86
|
if debug_level < 0
|
84
87
|
# there should be no logging if APPOPTICS_DEBUG_LEVEL == -1
|
85
88
|
# In Ruby level 5 is UNKNOWN and it can log, but level 6 is quiet
|
@@ -87,11 +90,7 @@ module AppOpticsAPM
|
|
87
90
|
else
|
88
91
|
AppOpticsAPM.logger.level = [4 - debug_level, 0].max
|
89
92
|
end
|
90
|
-
|
91
|
-
# the verbose setting is only relevant for ruby, ENV['APPOPTICS_GEM_VERBOSE'] overrides
|
92
|
-
if ENV.key?('APPOPTICS_GEM_VERBOSE')
|
93
|
-
AppOpticsAPM::Config[:verbose] = ENV['APPOPTICS_GEM_VERBOSE'].downcase == 'true'
|
94
|
-
end
|
93
|
+
AppOpticsAPM::Config[:debug_level] = debug_level
|
95
94
|
end
|
96
95
|
|
97
96
|
##
|
@@ -144,9 +143,6 @@ module AppOpticsAPM
|
|
144
143
|
# no guarantee of completeness in the user's config file
|
145
144
|
load(File.join(File.dirname(File.dirname(__FILE__)),
|
146
145
|
'rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb'))
|
147
|
-
|
148
|
-
# to make sure we include the service_key if it is set as an ENV var
|
149
|
-
check_env_vars
|
150
146
|
end
|
151
147
|
# rubocop:enable Metrics/AbcSize
|
152
148
|
|
@@ -243,11 +239,12 @@ module AppOpticsAPM
|
|
243
239
|
@@config[i][:log_args] = value
|
244
240
|
end
|
245
241
|
|
246
|
-
# Update liboboe if updating :tracing_mode
|
247
242
|
elsif key == :tracing_mode
|
248
|
-
|
243
|
+
# CAN'T DO THIS ANYMORE, ALL TRACING COMMUNICATION TO OBOE
|
244
|
+
# IS NOW HANDLED BY TransactionSettings
|
245
|
+
# AppOpticsAPM.set_tracing_mode(value.to_sym) if AppOpticsAPM.loaded
|
249
246
|
|
250
|
-
|
247
|
+
# Make sure that the mode is stored as a symbol
|
251
248
|
@@config[key.to_sym] = value.to_sym
|
252
249
|
end
|
253
250
|
end
|
@@ -84,18 +84,18 @@ module AppOpticsAPM
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# ActionController::Base
|
87
|
-
if defined?(ActionController::Base) && AppOpticsAPM::Config[:action_controller][:enabled]
|
87
|
+
if defined?(ActionController::Base) && AppOpticsAPM::Config[:action_controller][:enabled] && Rails::VERSION::MAJOR <= 6
|
88
88
|
AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting actioncontroller' if AppOpticsAPM::Config[:verbose]
|
89
89
|
require "appoptics_apm/frameworks/rails/inst/action_controller#{Rails::VERSION::MAJOR}"
|
90
90
|
if Rails::VERSION::MAJOR >= 5
|
91
91
|
ActionController::Base.send(:prepend, ::AppOpticsAPM::Inst::ActionController)
|
92
|
-
|
92
|
+
elsif Rails::VERSION::MAJOR < 5
|
93
93
|
AppOpticsAPM::Util.send_include(::ActionController::Base, AppOpticsAPM::Inst::ActionController)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
# ActionController::API - Rails 5
|
98
|
-
if defined?(ActionController::API) && AppOpticsAPM::Config[:action_controller_api][:enabled]
|
97
|
+
# ActionController::API - Rails 5 or via the rails-api gem
|
98
|
+
if defined?(ActionController::API) && AppOpticsAPM::Config[:action_controller_api][:enabled] && Rails::VERSION::MAJOR <= 6
|
99
99
|
AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting actioncontroller api' if AppOpticsAPM::Config[:verbose]
|
100
100
|
require "appoptics_apm/frameworks/rails/inst/action_controller_api"
|
101
101
|
ActionController::API.send(:prepend, ::AppOpticsAPM::Inst::ActionControllerAPI)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module AppOpticsAPM
|
5
|
+
module Inst
|
6
|
+
#
|
7
|
+
# ActionController
|
8
|
+
#
|
9
|
+
# This modules contains the instrumentation code specific
|
10
|
+
# to Rails v6
|
11
|
+
#
|
12
|
+
module ActionController
|
13
|
+
include AppOpticsAPM::Inst::RailsBase
|
14
|
+
|
15
|
+
def process_action(method_name, *args)
|
16
|
+
kvs = {
|
17
|
+
:Controller => self.class.name,
|
18
|
+
:Action => self.action_name,
|
19
|
+
}
|
20
|
+
request.env['appoptics_apm.controller'] = kvs[:Controller]
|
21
|
+
request.env['appoptics_apm.action'] = kvs[:Action]
|
22
|
+
|
23
|
+
return super(method_name, *args) unless AppOpticsAPM.tracing?
|
24
|
+
begin
|
25
|
+
kvs[:Backtrace] = AppOpticsAPM::API.backtrace if AppOpticsAPM::Config[:action_controller][:collect_backtraces]
|
26
|
+
|
27
|
+
AppOpticsAPM::API.log_entry('rails', kvs)
|
28
|
+
super(method_name, *args)
|
29
|
+
|
30
|
+
rescue Exception => e
|
31
|
+
AppOpticsAPM::API.log_exception('rails', e) if log_rails_error?(e)
|
32
|
+
raise
|
33
|
+
ensure
|
34
|
+
AppOpticsAPM::API.log_exit('rails')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# render
|
40
|
+
#
|
41
|
+
# Our render wrapper that calls 'trace', which will log if we are tracing
|
42
|
+
#
|
43
|
+
def render(*args, &blk)
|
44
|
+
trace('actionview') do
|
45
|
+
super(*args, &blk)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2016 SolarWinds, LLC.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
-
if defined?(ActionView::Base) && AppOpticsAPM::Config[:action_view][:enabled]
|
4
|
+
if defined?(ActionView::Base) && AppOpticsAPM::Config[:action_view][:enabled] && Rails::VERSION::MAJOR < 6
|
5
5
|
|
6
6
|
##
|
7
7
|
# ActionView Instrumentation is version dependent. ActionView 2.x is separate
|
@@ -5,13 +5,13 @@ require 'appoptics_apm/frameworks/rails/inst/connection_adapters/mysql'
|
|
5
5
|
require 'appoptics_apm/frameworks/rails/inst/connection_adapters/mysql2'
|
6
6
|
require 'appoptics_apm/frameworks/rails/inst/connection_adapters/postgresql'
|
7
7
|
|
8
|
-
if AppOpticsAPM::Config[:active_record][:enabled] && !defined?(JRUBY_VERSION)
|
8
|
+
if AppOpticsAPM::Config[:active_record][:enabled] && !defined?(JRUBY_VERSION) && Rails::VERSION::MAJOR <= 6
|
9
9
|
begin
|
10
10
|
adapter = ActiveRecord::Base.connection_config[:adapter]
|
11
11
|
|
12
12
|
if Rails::VERSION::MAJOR < 5
|
13
13
|
require 'appoptics_apm/frameworks/rails/inst/connection_adapters/utils'
|
14
|
-
|
14
|
+
elsif Rails::VERSION::MAJOR >= 5
|
15
15
|
require 'appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x'
|
16
16
|
end
|
17
17
|
|
@@ -23,13 +23,14 @@ module AppOpticsAPM
|
|
23
23
|
if current_trace.log?
|
24
24
|
case msg
|
25
25
|
when ::String
|
26
|
-
msg.strip.empty? ? msg : insert_before_empty_lines(msg, current_trace.for_log)
|
26
|
+
msg = msg.strip.empty? ? msg : insert_before_empty_lines(msg, current_trace.for_log)
|
27
27
|
when ::Exception
|
28
28
|
# conversion to String copied from Logger::Formatter private method #msg2str
|
29
|
-
"#{msg.message} (#{msg.class}) #{current_trace.for_log}\n" <<
|
30
|
-
(msg.backtrace || []).join("\n")
|
29
|
+
msg = ("#{msg.message} (#{msg.class}) #{current_trace.for_log}\n" <<
|
30
|
+
(msg.backtrace || []).join("\n"))
|
31
31
|
end
|
32
32
|
end
|
33
|
+
msg
|
33
34
|
end
|
34
35
|
|
35
36
|
def insert_before_empty_lines(msg, for_log)
|
@@ -35,11 +35,12 @@ module AppOpticsAPM
|
|
35
35
|
# args: 0: worker, 1: msg, 2: queue
|
36
36
|
report_kvs = collect_kvs(args)
|
37
37
|
|
38
|
+
# TODO remove completely once it is determined that this works without
|
38
39
|
# Something is happening across Celluloid threads where liboboe settings
|
39
40
|
# are being lost. So we re-set the tracing mode to assure
|
40
41
|
# we sample as desired. Setting the tracing mode will re-update
|
41
42
|
# the liboboe settings.
|
42
|
-
AppOpticsAPM.set_tracing_mode(AppOpticsAPM::Config[:tracing_mode].to_sym)
|
43
|
+
# AppOpticsAPM.set_tracing_mode(AppOpticsAPM::Config[:tracing_mode].to_sym)
|
43
44
|
|
44
45
|
# Continue the trace from the enqueue side?
|
45
46
|
if args[1].is_a?(Hash) && AppOpticsAPM::XTrace.valid?(args[1]['SourceTrace'])
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# Copyright (c) 2019 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module AppOpticsAPM
|
7
|
+
|
8
|
+
class OboeInitOptions
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_reader :reporter, :host, :service_name # exposing these mainly for testing
|
12
|
+
|
13
|
+
# TODO decide if these globals are useful when testing
|
14
|
+
# OBOE_HOSTNAME_ALIAS = 0
|
15
|
+
# OBOE_DEBUG_LEVEL = 1
|
16
|
+
# OBOE_LOGFILE = 2
|
17
|
+
#
|
18
|
+
# OBOE_MAX_TRANSACTIONS = 3
|
19
|
+
# OBOE_FLUSH_MAX_WAIT_TIME = 4
|
20
|
+
# OBOE_EVENTS_FLUSH_INTERVAL = 5
|
21
|
+
# OBOE_EVENTS_FLUSH_BATCH_SIZE = 6
|
22
|
+
#
|
23
|
+
# OBOE_REPORTER = 7
|
24
|
+
# OBOE_COLLECTOR = 8
|
25
|
+
# OBOE_SERVICE_KEY = 9
|
26
|
+
# OBOE_TRUSTEDPATH = 10
|
27
|
+
#
|
28
|
+
# OBOE_BUFSIZE = 11
|
29
|
+
# OBOE_TRACE_METRICS = 12
|
30
|
+
# OBOE_HISTOGRAM_PRECISION = 13
|
31
|
+
# OBOE_TOKEN_BUCKET_CAPACITY = 14
|
32
|
+
# OBOE_TOKEN_BUCKET_RATE = 15
|
33
|
+
# OBOE_FILE_SINGLE = 16
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
# optional hostname alias
|
37
|
+
@hostname_alias = ENV['APPOPTICS_HOSTNAME_ALIAS'] || AppOpticsAPM::Config[:hostname_alias] || ''
|
38
|
+
# level at which log messages will be written to log file (0-6)
|
39
|
+
@debug_level = (ENV['APPOPTICS_DEBUG_LEVEL'] || AppOpticsAPM::Config[:debug_level] || 3).to_i
|
40
|
+
# file name including path for log file
|
41
|
+
# TODO eventually find better way to combine ruby and oboe logs
|
42
|
+
@log_file_path = ENV['APPOPTICS_LOGFILE'] || ''
|
43
|
+
# maximum number of transaction names to track
|
44
|
+
@max_transactions = (ENV['APPOPTICS_MAX_TRANSACTIONS'] || -1).to_i
|
45
|
+
# maximum wait time for flushing data before terminating in milli seconds
|
46
|
+
@max_flush_wait_time = (ENV['APPOPTICS_FLUSH_MAX_WAIT_TIME'] || -1).to_i
|
47
|
+
# events flush timeout in seconds (threshold for batching messages before sending off)
|
48
|
+
@events_flush_interval = (ENV['APPOPTICS_EVENTS_FLUSH_INTERVAL'] || -1).to_i
|
49
|
+
# events flush batch size in KB (threshold for batching messages before sending off)
|
50
|
+
@event_flush_batch_size = (ENV['APPOPTICS_EVENTS_FLUSH_BATCH_SIZE'] || -1).to_i
|
51
|
+
|
52
|
+
# the reporter to be used (ssl, upd, file, null)
|
53
|
+
# collector endpoint (reporter=ssl), udp address (reporter=udp), or file path (reporter=file)
|
54
|
+
@reporter, @host = reporter_and_host
|
55
|
+
|
56
|
+
# the service key
|
57
|
+
@service_key = read_and_validate_service_key
|
58
|
+
# path to the SSL certificate (only for ssl)
|
59
|
+
@trusted_path = ENV['APPOPTICS_TRUSTEDPATH'] || ''
|
60
|
+
# size of the message buffer
|
61
|
+
@buffer_size = (ENV['APPOPTICS_BUFSIZE'] || -1).to_i
|
62
|
+
# flag indicating if trace metrics reporting should be enabled (default) or disabled
|
63
|
+
@trace_metrics = (ENV['APPOPTICS_TRACE_METRICS'] || -1).to_i
|
64
|
+
# the histogram precision (only for ssl)
|
65
|
+
@histogram_precision = (ENV['APPOPTICS_HISTOGRAM_PRECISION'] || -1).to_i
|
66
|
+
# custom token bucket capacity
|
67
|
+
@token_bucket_capacity = (ENV['APPOPTICS_TOKEN_BUCKET_CAPACITY'] || -1).to_i
|
68
|
+
# custom token bucket rate
|
69
|
+
@token_bucket_rate = (ENV['APPOPTICS_TOKEN_BUCKET_RATE'] || -1).to_i
|
70
|
+
# use single files in file reporter for each event
|
71
|
+
@file_single = (ENV['APPOPTICS_REPORTER_FILE_SINGLE'].to_s.downcase == 'true') ? 1 : 0
|
72
|
+
end
|
73
|
+
|
74
|
+
def re_init # for testing with changed ENV vars
|
75
|
+
initialize
|
76
|
+
end
|
77
|
+
|
78
|
+
def array_for_oboe
|
79
|
+
[
|
80
|
+
@hostname_alias,
|
81
|
+
@debug_level,
|
82
|
+
@log_file_path,
|
83
|
+
@max_transactions,
|
84
|
+
@max_flush_wait_time,
|
85
|
+
@events_flush_interval,
|
86
|
+
@event_flush_batch_size,
|
87
|
+
|
88
|
+
@reporter,
|
89
|
+
@host,
|
90
|
+
@service_key,
|
91
|
+
@trusted_path,
|
92
|
+
@buffer_size,
|
93
|
+
@trace_metrics,
|
94
|
+
@histogram_precision,
|
95
|
+
@token_bucket_capacity,
|
96
|
+
@token_bucket_rate,
|
97
|
+
@file_single
|
98
|
+
]
|
99
|
+
end
|
100
|
+
|
101
|
+
def service_key_ok?
|
102
|
+
return !@service_key.empty? || @reporter != 'ssl'
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def reporter_and_host
|
108
|
+
|
109
|
+
reporter = ENV['APPOPTICS_REPORTER'] || 'ssl'
|
110
|
+
# override with 'file', e.g. when running tests
|
111
|
+
# changed my mind => set the right reporter in the env when running tests !!!
|
112
|
+
# reporter = 'file' if ENV.key?('APPOPTICS_GEM_TEST')
|
113
|
+
|
114
|
+
host = ''
|
115
|
+
case reporter
|
116
|
+
when 'ssl', 'file'
|
117
|
+
host = ENV['APPOPTICS_COLLECTOR'] || ''
|
118
|
+
when 'udp'
|
119
|
+
host = ENV['APPOPTICS_COLLECTOR'] ||
|
120
|
+
"#{AppOpticsAPM::Config[:reporter_host]}:#{AppOpticsAPM::Config[:reporter_port]}"
|
121
|
+
# TODO decide what to do
|
122
|
+
# ____ AppOpticsAPM::Config[:reporter_host] and
|
123
|
+
# ____ AppOpticsAPM::Config[:reporter_port] were moved here from
|
124
|
+
# ____ oboe_metal.rb and are not documented anywhere
|
125
|
+
# ____ udp is for internal use only
|
126
|
+
when 'null'
|
127
|
+
host = ''
|
128
|
+
end
|
129
|
+
|
130
|
+
[reporter, host]
|
131
|
+
end
|
132
|
+
|
133
|
+
def read_and_validate_service_key
|
134
|
+
return '' unless @reporter == 'ssl'
|
135
|
+
|
136
|
+
service_key = ENV['APPOPTICS_SERVICE_KEY'] || AppOpticsAPM::Config[:service_key]
|
137
|
+
unless service_key
|
138
|
+
AppOpticsAPM.logger.error "[appoptics_apm/oboe_options] APPOPTICS_SERVICE_KEY not configured."
|
139
|
+
return ''
|
140
|
+
end
|
141
|
+
|
142
|
+
match = service_key.match( /([^:]+)(:{0,1})(.*)/ )
|
143
|
+
token = match[1]
|
144
|
+
service_name = match[3]
|
145
|
+
|
146
|
+
return '' unless validate_token(token)
|
147
|
+
return '' unless validate_transform_service_name(service_name)
|
148
|
+
|
149
|
+
return "#{token}:#{service_name}"
|
150
|
+
end
|
151
|
+
|
152
|
+
def validate_token(token)
|
153
|
+
if (token !~ /^[0-9a-fA-F]{64}|[0-9a-zA-Z_\-]{71}$/) && ENV['APPOPTICS_COLLECTOR'] != "sslcollector:12222"
|
154
|
+
masked = "#{token[0..3]}...#{token[-4..-1]}"
|
155
|
+
AppOpticsAPM.logger.error "[appoptics_apm/oboe_options] APPOPTICS_SERVICE_KEY problem. API Token in wrong format. Masked token: #{masked}"
|
156
|
+
return false
|
157
|
+
end
|
158
|
+
|
159
|
+
true
|
160
|
+
end
|
161
|
+
|
162
|
+
def validate_transform_service_name(service_name)
|
163
|
+
service_name = 'test_ssl_collector' if ENV['APPOPTICS_COLLECTOR'] == "sslcollector:12222"
|
164
|
+
if service_name.empty?
|
165
|
+
AppOpticsAPM.logger.error "[appoptics_apm/oboe_options] APPOPTICS_SERVICE_KEY problem. Service Name is missing"
|
166
|
+
return false
|
167
|
+
end
|
168
|
+
|
169
|
+
name = service_name.dup
|
170
|
+
name.downcase!
|
171
|
+
name.gsub!(/[^a-z0-9.:_-]/, '')
|
172
|
+
name = name[0..254]
|
173
|
+
|
174
|
+
if name != service_name
|
175
|
+
AppOpticsAPM.logger.warn "[appoptics_apm/oboe_options] APPOPTICS_SERVICE_KEY problem. Service Name transformed from #{service_name} to #{name}"
|
176
|
+
service_name = name
|
177
|
+
end
|
178
|
+
@service_name = service_name # instance variable used in testing
|
179
|
+
true
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
@@ -17,7 +17,7 @@ AO_TRACING_DECISIONS_QUEUE_FULL = 5
|
|
17
17
|
|
18
18
|
module AppOpticsAPM
|
19
19
|
##
|
20
|
-
# This module helps with setting up the filters and applying them
|
20
|
+
# This module helps with setting up the transaction filters and applying them
|
21
21
|
#
|
22
22
|
class TransactionSettings
|
23
23
|
|
@@ -40,8 +40,9 @@ module AppOpticsAPM
|
|
40
40
|
return
|
41
41
|
end
|
42
42
|
|
43
|
-
if
|
43
|
+
if tracing_mode_disabled? && !tracing_enabled?(url) ||
|
44
44
|
tracing_disabled?(url)
|
45
|
+
|
45
46
|
tracing_mode = AO_TRACING_DISABLED
|
46
47
|
end
|
47
48
|
|
@@ -51,7 +52,6 @@ module AppOpticsAPM
|
|
51
52
|
|
52
53
|
metrics, sample, @rate, @source, return_code = AppOpticsAPM::Context.getDecisions(*args)
|
53
54
|
|
54
|
-
puts "return_code class: #{return_code.class}" unless return_code.is_a? Integer
|
55
55
|
if return_code > AO_TRACING_DECISIONS_OK
|
56
56
|
AppOpticsAPM.logger.warn "[appoptics-apm/sample] Problem getting the sampling decisions, code: #{return_code}"
|
57
57
|
end
|
@@ -65,6 +65,14 @@ module AppOpticsAPM
|
|
65
65
|
end
|
66
66
|
|
67
67
|
private
|
68
|
+
|
69
|
+
##
|
70
|
+
# check the config setting for :tracing_mode
|
71
|
+
def tracing_mode_disabled?
|
72
|
+
AppOpticsAPM::Config[:tracing_mode] &&
|
73
|
+
[:disabled, :never].include?(AppOpticsAPM::Config[:tracing_mode])
|
74
|
+
end
|
75
|
+
|
68
76
|
##
|
69
77
|
# tracing_enabled?
|
70
78
|
#
|
@@ -6,9 +6,9 @@ module AppOpticsAPM
|
|
6
6
|
# The current version of the gem. Used mainly by
|
7
7
|
# appoptics_apm.gemspec during gem build process
|
8
8
|
module Version
|
9
|
-
MAJOR = 4
|
10
|
-
MINOR =
|
11
|
-
PATCH =
|
9
|
+
MAJOR = 4 # breaking,
|
10
|
+
MINOR = 8 # feature,
|
11
|
+
PATCH = 4 # fix => BFF
|
12
12
|
|
13
13
|
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
14
14
|
end
|
data/lib/oboe_metal.rb
CHANGED
@@ -18,25 +18,12 @@ module AppOpticsAPM
|
|
18
18
|
# Start the AppOpticsAPM Reporter
|
19
19
|
#
|
20
20
|
def start
|
21
|
+
AppOpticsAPM.loaded = false unless AppOpticsAPM::OboeInitOptions.instance.service_key_ok?
|
21
22
|
return unless AppOpticsAPM.loaded
|
22
23
|
|
23
24
|
begin
|
24
|
-
options =
|
25
|
-
|
26
|
-
ENV['APPOPTICS_REPORTER'] = 'file' if ENV.key?('APPOPTICS_GEM_TEST')
|
27
|
-
|
28
|
-
case ENV['APPOPTICS_REPORTER']
|
29
|
-
when 'file'
|
30
|
-
ENV['APPOPTICS_REPORTER_FILE'] = TRACE_FILE
|
31
|
-
when 'udp'
|
32
|
-
ENV['APPOPTICS_REPORTER_UDP'] = "#{AppOpticsAPM::Config[:reporter_host]}:#{AppOpticsAPM::Config[:reporter_port]}"
|
33
|
-
else # default is ssl, service_key is mandatory
|
34
|
-
return unless valid_service_key?
|
35
|
-
# Oboe will override these settings if there are env settings for them
|
36
|
-
options << AppOpticsAPM::Config[:service_key].to_s
|
37
|
-
options << AppOpticsAPM::Config[:hostname_alias].to_s
|
38
|
-
options << AppOpticsAPM::Config[:debug_level] unless AppOpticsAPM::Config[:debug_level].nil?
|
39
|
-
end
|
25
|
+
options = AppOpticsAPM::OboeInitOptions.instance.array_for_oboe # creates an array with the options in the right order
|
26
|
+
|
40
27
|
AppOpticsAPM.reporter = Oboe_metal::Reporter.new(*options)
|
41
28
|
|
42
29
|
# Only report __Init from here if we are not instrumenting a framework.
|
@@ -52,19 +39,6 @@ module AppOpticsAPM
|
|
52
39
|
end
|
53
40
|
alias :restart :start
|
54
41
|
|
55
|
-
def valid_service_key?
|
56
|
-
service_key = (ENV['APPOPTICS_SERVICE_KEY'] || AppOpticsAPM::Config[:service_key]).to_s
|
57
|
-
if service_key == ''
|
58
|
-
AppOpticsAPM.logger.warn '[appoptics_apm/warn] APPOPTICS_SERVICE_KEY not set. Cannot submit data.'
|
59
|
-
AppOpticsAPM.loaded = false
|
60
|
-
return false
|
61
|
-
elsif service_key !~ /^[0-9a-fA-F]{64}:[-.:_?\\\/\w ]{1,255}$/
|
62
|
-
AppOpticsAPM.logger.warn '[appoptics_apm/warn] APPOPTICS_SERVICE_KEY problem. No service name or api token in wrong format. Cannot submit data.'
|
63
|
-
AppOpticsAPM.loaded = false
|
64
|
-
return false
|
65
|
-
end
|
66
|
-
true
|
67
|
-
end
|
68
42
|
##
|
69
43
|
# sendReport
|
70
44
|
#
|
@@ -89,7 +63,7 @@ module AppOpticsAPM
|
|
89
63
|
# Truncates the trace output file to zero
|
90
64
|
#
|
91
65
|
def clear_all_traces
|
92
|
-
File.truncate(
|
66
|
+
File.truncate(AppOpticsAPM::OboeInitOptions.instance.host, 0)
|
93
67
|
end
|
94
68
|
|
95
69
|
##
|
@@ -98,14 +72,14 @@ module AppOpticsAPM
|
|
98
72
|
# Retrieves all traces written to the trace file
|
99
73
|
#
|
100
74
|
def get_all_traces
|
101
|
-
io = File.open(
|
75
|
+
io = File.open(AppOpticsAPM::OboeInitOptions.instance.host, 'r')
|
102
76
|
contents = io.readlines(nil)
|
77
|
+
io.close
|
103
78
|
|
104
79
|
return contents if contents.empty?
|
105
80
|
|
106
81
|
traces = []
|
107
82
|
|
108
|
-
#
|
109
83
|
# We use Gem.loaded_spec because older versions of the bson
|
110
84
|
# gem didn't even have a version embedded in the gem. If the
|
111
85
|
# gem isn't in the bundle, it should rightfully error out
|
@@ -140,49 +114,49 @@ module AppOpticsAPM
|
|
140
114
|
end
|
141
115
|
|
142
116
|
class << self
|
143
|
-
def sample?(opts = {})
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
rescue StandardError => e
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
def set_tracing_mode(mode)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
117
|
+
# def sample?(opts = {})
|
118
|
+
# # Return false if no-op mode
|
119
|
+
# return false unless AppOpticsAPM.loaded
|
120
|
+
#
|
121
|
+
# # Assure defaults since SWIG enforces Strings
|
122
|
+
# xtrace = opts[:xtrace] ? opts[:xtrace].to_s.strip : APPOPTICS_STR_BLANK
|
123
|
+
#
|
124
|
+
# # the first arg has changed to be the service name, blank means to use the default (from the service key)
|
125
|
+
# rv = AppOpticsAPM::Context.sampleRequest(APPOPTICS_STR_BLANK, xtrace)
|
126
|
+
#
|
127
|
+
# if rv == 0
|
128
|
+
# AppOpticsAPM.sample_rate = -1
|
129
|
+
# AppOpticsAPM.sample_source = -1
|
130
|
+
# false
|
131
|
+
# else
|
132
|
+
# # liboboe version > 1.3.1 returning a bit masked integer with SampleRate and
|
133
|
+
# # source embedded
|
134
|
+
# AppOpticsAPM.sample_rate = (rv & SAMPLE_RATE_MASK)
|
135
|
+
# AppOpticsAPM.sample_source = (rv & SAMPLE_SOURCE_MASK) >> 24
|
136
|
+
# true
|
137
|
+
# end
|
138
|
+
# rescue StandardError => e
|
139
|
+
# AppOpticsAPM.logger.debug "[oboe/error] sample? error: #{e.inspect}"
|
140
|
+
# false
|
141
|
+
# end
|
142
|
+
|
143
|
+
# def set_tracing_mode(mode)
|
144
|
+
# return unless AppOpticsAPM.loaded
|
145
|
+
#
|
146
|
+
# value = mode.to_sym
|
147
|
+
#
|
148
|
+
# case value
|
149
|
+
# when :disabled, :never
|
150
|
+
# AppOpticsAPM::Context.setTracingMode(APPOPTICS_TRACE_DISABLED)
|
151
|
+
#
|
152
|
+
# when :enabled, :always
|
153
|
+
# AppOpticsAPM::Context.setTracingMode(APPOPTICS_TRACE_ENABLED)
|
154
|
+
#
|
155
|
+
# else
|
156
|
+
# AppOpticsAPM.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
|
157
|
+
# AppOpticsAPM::Context.setTracingMode(APPOPTICS_TRACE_DISABLED)
|
158
|
+
# end
|
159
|
+
# end
|
186
160
|
|
187
161
|
def set_sample_rate(rate)
|
188
162
|
return unless AppOpticsAPM.loaded
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoptics_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maia Engeli
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- build_gem_upload_to_packagecloud.sh
|
133
133
|
- examples/SDK/01_basic_tracing.rb
|
134
134
|
- examples/carrying_context.rb
|
135
|
+
- ext/oboe_metal/README.md
|
135
136
|
- ext/oboe_metal/extconf.rb
|
136
137
|
- ext/oboe_metal/lib/.keep
|
137
138
|
- ext/oboe_metal/noop/noop.c
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb
|
162
163
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb
|
163
164
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb
|
165
|
+
- lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb
|
164
166
|
- lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb
|
165
167
|
- lib/appoptics_apm/frameworks/rails/inst/action_view.rb
|
166
168
|
- lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb
|
@@ -208,6 +210,7 @@ files:
|
|
208
210
|
- lib/appoptics_apm/noop/README.md
|
209
211
|
- lib/appoptics_apm/noop/context.rb
|
210
212
|
- lib/appoptics_apm/noop/metadata.rb
|
213
|
+
- lib/appoptics_apm/oboe_init_options.rb
|
211
214
|
- lib/appoptics_apm/ruby.rb
|
212
215
|
- lib/appoptics_apm/sdk/current_trace.rb
|
213
216
|
- lib/appoptics_apm/sdk/custom_metrics.rb
|
@@ -254,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
257
|
version: '0'
|
255
258
|
requirements: []
|
256
259
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.
|
260
|
+
rubygems_version: 2.6.11
|
258
261
|
signing_key:
|
259
262
|
specification_version: 4
|
260
263
|
summary: AppOptics APM performance instrumentation gem for Ruby
|