appoptics_apm 4.2.3 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +5 -0
- data/.travis.yml +15 -12
- data/Gemfile +0 -1
- data/README.md +7 -38
- data/Rakefile +17 -1
- data/appoptics_apm.gemspec +2 -0
- data/{build_gems.sh → build_gem.sh} +1 -1
- data/build_gem_upload_to_packagecloud.sh +15 -0
- data/examples/SDK/01_basic_tracing.rb +1 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/bson/bson.h +1 -2
- data/ext/oboe_metal/src/bson/platform_hacks.h +4 -4
- data/lib/appoptics_apm.rb +28 -30
- data/lib/appoptics_apm/api/logging.rb +13 -27
- data/lib/appoptics_apm/api/metrics.rb +25 -11
- data/lib/appoptics_apm/api/profiling.rb +6 -11
- data/lib/appoptics_apm/api/tracing.rb +3 -24
- data/lib/appoptics_apm/base.rb +7 -32
- data/lib/appoptics_apm/config.rb +26 -4
- data/lib/appoptics_apm/frameworks/grape.rb +10 -8
- data/lib/appoptics_apm/frameworks/padrino.rb +3 -0
- data/lib/appoptics_apm/frameworks/rails.rb +20 -42
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +4 -6
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -9
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
- data/lib/appoptics_apm/frameworks/sinatra.rb +4 -1
- data/lib/appoptics_apm/inst/bunny-client.rb +16 -18
- data/lib/appoptics_apm/inst/memcached.rb +6 -10
- data/lib/appoptics_apm/inst/moped.rb +1 -1
- data/lib/appoptics_apm/inst/rack.rb +13 -15
- data/lib/appoptics_apm/inst/sidekiq-worker.rb +1 -1
- data/lib/appoptics_apm/inst/typhoeus.rb +4 -2
- data/lib/appoptics_apm/loading.rb +1 -1
- data/lib/appoptics_apm/sdk.rb +48 -50
- data/lib/appoptics_apm/version.rb +1 -1
- data/lib/appoptics_apm/xtrace.rb +1 -1
- data/lib/oboe_metal.rb +13 -11
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +45 -7
- metadata +5 -16
- data/.codeclimate.yml +0 -43
- data/Dockerfile +0 -41
- data/Dockerfile_alpine +0 -66
- data/Dockerfile_test +0 -73
- data/config/initializers/.keep +0 -0
- data/docker-compose.yml +0 -95
- data/ext/oboe_metal/tests/test.rb +0 -11
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller2.rb +0 -61
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_2x.rb +0 -56
- data/ruby_setup.sh +0 -49
- data/run_docker_build_gem_upload_to_packagecloud.sh +0 -20
- data/run_tests_docker.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9cd8f06bd5c7b8d7b31daf27b9208a3e528ea3ee65f2cc8b9331eeb823f7e52
|
4
|
+
data.tar.gz: 2356b83ed28ad90de5e5daecdf54187e45b742c63be1c5e5835db0588ec257ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef1f899cc31324804807be8536b604ac2dc5a163547ac293bea3e14e1ea8595319d33b232c350e2091a994496ad78fed44e302432c1e226e75b6abaaf24a36e
|
7
|
+
data.tar.gz: 8caef4745de30fc3715d2ab19a3ae7f1fd39741f5ef935dcec2273e8af3101bbdf7d89c93a4042e589ca1cb5111a8be35069d22ff6af7e45d560a48392a00c67
|
data/.gitignore
CHANGED
@@ -15,8 +15,13 @@ ext/oboe_metal/src/oboe.h
|
|
15
15
|
ext/oboe_metal/src/oboe.hpp
|
16
16
|
ext/oboe_metal/src/oboe_debug.h
|
17
17
|
ext/oboe_metal/src/oboe_wrap.cxx
|
18
|
+
ext/oboe_metal/src/bson/*
|
18
19
|
log/
|
19
20
|
.vagrant
|
20
21
|
gemfiles/.bundle
|
21
22
|
swig*
|
22
23
|
*.gem
|
24
|
+
.yardoc
|
25
|
+
coverage
|
26
|
+
doc
|
27
|
+
.*byebug*
|
data/.travis.yml
CHANGED
@@ -6,37 +6,38 @@ cache:
|
|
6
6
|
- vendor/bundle
|
7
7
|
|
8
8
|
env:
|
9
|
-
- DBTYPE=mysql
|
10
|
-
- DBTYPE=mysql2
|
11
9
|
- DBTYPE=postgresql
|
10
|
+
# - DBTYPE=mysql2
|
11
|
+
# - DBTYPE=mysql
|
12
12
|
|
13
13
|
rvm:
|
14
14
|
- 2.5.1
|
15
|
-
- 2.4.4
|
16
|
-
- 2.3.6
|
15
|
+
# - 2.4.4
|
16
|
+
# - 2.3.6
|
17
17
|
# - jruby-9.0.5.0
|
18
18
|
|
19
19
|
gemfile:
|
20
|
-
- gemfiles/noop.gemfile
|
21
20
|
- gemfiles/libraries.gemfile
|
21
|
+
- gemfiles/unit.gemfile
|
22
22
|
- gemfiles/instrumentation_mocked.gemfile
|
23
|
-
- gemfiles/instrumentation_mocked_oldgems.gemfile
|
23
|
+
# - gemfiles/instrumentation_mocked_oldgems.gemfile
|
24
24
|
- gemfiles/frameworks.gemfile
|
25
|
-
|
25
|
+
- gemfiles/rails52.gemfile
|
26
|
+
# - gemfiles/rails51.gemfile
|
26
27
|
- gemfiles/rails42.gemfile
|
27
|
-
- gemfiles/
|
28
|
-
# - gemfiles/rails52.gemfile # postgres test needs fixing first
|
28
|
+
## - gemfiles/rails32.gemfile # We currently are not supporting Rails 3.2
|
29
29
|
- gemfiles/delayed_job.gemfile
|
30
|
+
- gemfiles/noop.gemfile
|
30
31
|
|
31
32
|
matrix:
|
32
33
|
exclude:
|
33
34
|
- rvm: 2.5.1
|
34
35
|
env: DBTYPE=mysql
|
35
|
-
- rvm: 2.4.3
|
36
|
-
env: DBTYPE=mysql
|
37
36
|
- rvm: 2.4.4
|
38
37
|
env: DBTYPE=mysql
|
39
38
|
|
39
|
+
- gemfile: gemfiles/unit.gemfile
|
40
|
+
env: DBTYPE=mysql
|
40
41
|
- gemfile: gemfiles/noop.gemfile
|
41
42
|
env: DBTYPE=mysql
|
42
43
|
- gemfile: gemfiles/libraries.gemfile
|
@@ -54,6 +55,8 @@ matrix:
|
|
54
55
|
- gemfile: gemfiles/delayed_job.gemfile
|
55
56
|
env: DBTYPE=mysql
|
56
57
|
|
58
|
+
- gemfile: gemfiles/unit.gemfile
|
59
|
+
env: DBTYPE=mysql2
|
57
60
|
- gemfile: gemfiles/noop.gemfile
|
58
61
|
env: DBTYPE=mysql2
|
59
62
|
- gemfile: gemfiles/libraries.gemfile
|
@@ -71,7 +74,7 @@ matrix:
|
|
71
74
|
# We currently are not supporting Rails 3.2
|
72
75
|
- rvm: 2.5.1
|
73
76
|
gemfile: gemfiles/rails32.gemfile
|
74
|
-
- rvm: 2.4.
|
77
|
+
- rvm: 2.4.4
|
75
78
|
gemfile: gemfiles/rails32.gemfile
|
76
79
|
|
77
80
|
# - rvm: jruby-9.0.5.0
|
data/Gemfile
CHANGED
@@ -13,7 +13,6 @@ group :development, :test do
|
|
13
13
|
gem 'rubocop', require: false
|
14
14
|
gem 'ruby-prof'
|
15
15
|
gem 'benchmark-ips'
|
16
|
-
|
17
16
|
gem 'ruby-debug', :platforms => [:mri_18, :jruby]
|
18
17
|
gem 'debugger', :platform => :mri_19
|
19
18
|
gem 'byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24]
|
data/README.md
CHANGED
@@ -11,12 +11,12 @@ Mongo, Memcache, ActiveRecord, Cassandra, Rack, Resque
|
|
11
11
|
It requires an [AppOptics](https://www.appoptics.com/) account to view metrics. Get yours,
|
12
12
|
[it's free](https://my.appoptics.com/sign_up).
|
13
13
|
|
14
|
-
[![Gem Version](https://badge.fury.io/rb/appoptics_apm.
|
15
|
-
[![Build Status](https://travis-ci.
|
16
|
-
[![
|
14
|
+
[![Gem Version](https://badge.fury.io/rb/appoptics_apm.svg)](https://badge.fury.io/rb/appoptics_apm)
|
15
|
+
[![Build Status](https://travis-ci.org/appoptics/appoptics-apm-ruby.png?branch=master)](https://travis-ci.org/appoptics/appoptics-apm-ruby)
|
16
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability)
|
17
17
|
|
18
|
-
_Note: The repository
|
19
|
-
`git remote set-url origin git@github.com:
|
18
|
+
_Note: The repository is now at https://github.com/appoptics/appoptics-apm-ruby Please update your github remotes with
|
19
|
+
`git remote set-url origin git@github.com:appoptics/appoptics-apm-ruby.git`._
|
20
20
|
|
21
21
|
# Documentation
|
22
22
|
|
@@ -384,41 +384,10 @@ You can read more about Ruby gems with C extensions in the
|
|
384
384
|
|
385
385
|
## Running the Tests
|
386
386
|
|
387
|
-
|
388
|
-
1. They only run on Linux systems, because of the c-lib used by the appoptics-apm gem.
|
389
|
-
1. The are split up, different suites can be run with `bundle exec rake test` depending on the Gemfile set in the
|
390
|
-
environment variable `BUNDLE_GEMFILE`.
|
391
|
-
1. Some are integration tests that depend on external services and databases.
|
392
|
-
|
393
|
-
Unless you are developing on a linux system it may be easiest to run the tests using docker. The docker test setup is
|
394
|
-
currently being improved to become more comprehensive.
|
395
|
-
|
396
|
-
The command `./run_tests_docker.rb` will run the tests and dump the output to a file in the log folder.
|
397
|
-
In the shell it will print the commands to run a single test suite, e.g.
|
398
|
-
|
399
|
-
```bash
|
400
|
-
docker-compose run --rm --service-ports ruby_appoptics_apm /code/ruby-appoptics_apm/ruby_setup.sh 2.5.1 gemfiles/libraries.gemfile DBTYPE=postgresql
|
401
|
-
```
|
402
|
-
|
403
|
-
If `true` is added to that command line it will stop in a sheel in the docker container, which is great for debugging.
|
404
|
-
|
405
|
-
```bash
|
406
|
-
docker-compose run --rm --service-ports ruby_appoptics_apm /code/ruby-appoptics_apm/ruby_setup.sh 2.5.1 gemfiles/libraries.gemfile DBTYPE=postgresql true
|
407
|
-
```
|
408
|
-
|
409
|
-
The gem is setup to be debugged with `pry` and `pry-byebug`, add the following lines in the code for a break:
|
410
|
-
```ruby
|
411
|
-
require 'pry'
|
412
|
-
require 'pry-byebug'
|
413
|
-
byebug
|
414
|
-
```
|
415
|
-
|
416
|
-
If you need further assistance running tests feel free to get in touch with the main developer.
|
417
|
-
|
418
|
-
|
387
|
+
See the README in the test directory.
|
419
388
|
|
420
389
|
# License
|
421
390
|
|
422
391
|
Copyright (c) 2018 SolarWinds, LLC
|
423
392
|
|
424
|
-
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
@@ -53,6 +53,9 @@ Rake::TestTask.new do |t|
|
|
53
53
|
t.test_files = FileList['test/mocked/*_test.rb']
|
54
54
|
when /noop/
|
55
55
|
t.test_files = FileList['test/noop/*_test.rb']
|
56
|
+
when /unit/
|
57
|
+
t.test_files = FileList['test/unit/*_test.rb'] +
|
58
|
+
FileList['test/unit/*/*_test.rb']
|
56
59
|
end
|
57
60
|
|
58
61
|
if defined?(JRUBY_VERSION)
|
@@ -60,6 +63,18 @@ Rake::TestTask.new do |t|
|
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
66
|
+
desc "Run all test suites defined by travis"
|
67
|
+
task "docker_tests" do
|
68
|
+
Dir.chdir('test/run_tests')
|
69
|
+
exec('docker-compose run --service-ports ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh test')
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Start docker container for testing and debugging"
|
73
|
+
task "docker" do
|
74
|
+
Dir.chdir('test/run_tests')
|
75
|
+
exec('docker-compose run --service-ports ruby_appoptics /code/ruby-appoptics/test/run_tests/ruby_setup.sh bash')
|
76
|
+
end
|
77
|
+
|
63
78
|
desc "Fetch extension dependency files"
|
64
79
|
task :fetch_ext_deps do
|
65
80
|
swig_version = %x{swig -version} rescue ''
|
@@ -89,6 +104,7 @@ task :fetch_ext_deps do
|
|
89
104
|
# oboe and bson header files
|
90
105
|
FileUtils.mkdir_p(File.join(ext_src_dir, 'bson'))
|
91
106
|
%w(oboe.h oboe.hpp oboe_debug.h oboe.i bson/bson.h bson/platform_hacks.h).each do |filename|
|
107
|
+
# %w(oboe.h oboe_debug.h oboe.i bson/bson.h bson/platform_hacks.h).each do |filename|
|
92
108
|
remote_file = File.join(oboe_s3_dir, 'include', filename)
|
93
109
|
local_file = File.join(ext_src_dir, filename)
|
94
110
|
|
@@ -130,7 +146,7 @@ task :compile do
|
|
130
146
|
else
|
131
147
|
Dir.chdir(pwd)
|
132
148
|
puts '!! Extension failed to build (see above). Have the required binary and header files been fetched?'
|
133
|
-
puts '!! Try the tasks in this order: clean >
|
149
|
+
puts '!! Try the tasks in this order: clean > fetch_ext_deps > compile.'
|
134
150
|
end
|
135
151
|
else
|
136
152
|
puts '== Nothing to do under JRuby.'
|
data/appoptics_apm.gemspec
CHANGED
@@ -32,6 +32,8 @@ Gem::Specification.new do |s|
|
|
32
32
|
|
33
33
|
s.add_runtime_dependency('json', '>= 0')
|
34
34
|
s.add_runtime_dependency('no_proxy_fix', '~> 0.1.2', '>= 0.1.2')
|
35
|
+
s.add_runtime_dependency('simplecov', '>= 0.16.0') if ENV["SIMPLECOV_COVERAGE"]
|
36
|
+
s.add_runtime_dependency('simplecov-console', '>= 0.4.0') if ENV["SIMPLECOV_COVERAGE"]
|
35
37
|
|
36
38
|
# Development dependencies used in gem development & testing
|
37
39
|
s.add_development_dependency('rake', '>= 0.9.0')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# build the gem
|
4
|
+
./build_gem.sh
|
5
|
+
|
6
|
+
# save current rbenv setting and switch to 2.4.1 for the package_cloud commands
|
7
|
+
current_ruby=`rbenv global`
|
8
|
+
rbenv global 2.4.1
|
9
|
+
|
10
|
+
# prerequisite: package_cloud token needs to be in ~/.packagecloud
|
11
|
+
gem=`ls -dt1 appoptics_apm-[^pre]*.gem | head -1`
|
12
|
+
package_cloud push AppOptics/apm-instrumentation $gem
|
13
|
+
|
14
|
+
# restore ruby version
|
15
|
+
rbenv global $current_ruby
|
data/ext/oboe_metal/src/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.2
|
@@ -70,7 +70,7 @@ typedef struct {
|
|
70
70
|
|
71
71
|
#pragma pack(1)
|
72
72
|
typedef union{
|
73
|
-
char bytes[12];
|
73
|
+
char bytes[12]; // Flawfinder: ignore
|
74
74
|
int ints[3];
|
75
75
|
} bson_oid_t;
|
76
76
|
#pragma pack()
|
@@ -170,7 +170,6 @@ char * bson_buffer_finish( bson_buffer * b );
|
|
170
170
|
void bson_buffer_destroy( bson_buffer * b );
|
171
171
|
|
172
172
|
bson_buffer * bson_append_oid( bson_buffer * b , const char * name , const bson_oid_t* oid );
|
173
|
-
bson_buffer * bson_append_new_oid( bson_buffer * b , const char * name );
|
174
173
|
bson_buffer * bson_append_int( bson_buffer * b , const char * name , const int i );
|
175
174
|
bson_buffer * bson_append_long( bson_buffer * b , const char * name , const int64_t i );
|
176
175
|
bson_buffer * bson_append_double( bson_buffer * b , const char * name , const double d );
|
@@ -51,11 +51,11 @@ typedef long long int int64_t;
|
|
51
51
|
#ifdef MONGO_BIG_ENDIAN
|
52
52
|
#define bson_little_endian64(out, in) ( bson_swap_endian64(out, in) )
|
53
53
|
#define bson_little_endian32(out, in) ( bson_swap_endian32(out, in) )
|
54
|
-
#define bson_big_endian64(out, in) (
|
55
|
-
#define bson_big_endian32(out, in) (
|
54
|
+
#define bson_big_endian64(out, in) ( memmove(out, in, 8) )
|
55
|
+
#define bson_big_endian32(out, in) ( memmove(out, in, 4) )
|
56
56
|
#else
|
57
|
-
#define bson_little_endian64(out, in) (
|
58
|
-
#define bson_little_endian32(out, in) (
|
57
|
+
#define bson_little_endian64(out, in) ( memmove(out, in, 8) )
|
58
|
+
#define bson_little_endian32(out, in) ( memmove(out, in, 4) )
|
59
59
|
#define bson_big_endian64(out, in) ( bson_swap_endian64(out, in) )
|
60
60
|
#define bson_big_endian32(out, in) ( bson_swap_endian32(out, in) )
|
61
61
|
#endif
|
data/lib/appoptics_apm.rb
CHANGED
@@ -13,46 +13,44 @@ begin
|
|
13
13
|
require 'appoptics_apm/util'
|
14
14
|
require 'appoptics_apm/xtrace'
|
15
15
|
require 'appoptics_apm/support'
|
16
|
+
require 'appoptics_apm/base'
|
17
|
+
AppOpticsAPM.loaded = false
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
unless defined?(OboeHeroku)
|
20
|
-
require 'appoptics_apm/base'
|
21
|
-
AppOpticsAPM.loaded = false
|
19
|
+
require 'appoptics_apm/config'
|
20
|
+
AppOpticsAPM::Config.load_config_file
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
22
|
+
begin
|
23
|
+
if RUBY_PLATFORM == 'java'
|
24
|
+
require '/usr/local/tracelytics/tracelyticsagent.jar'
|
25
|
+
require 'joboe_metal'
|
26
|
+
elsif RUBY_PLATFORM =~ /linux/
|
27
|
+
require_relative './oboe_metal.so'
|
28
|
+
require 'oboe_metal.rb' # sets AppOpticsAPM.loaded = true if successful
|
29
|
+
else
|
30
|
+
$stderr.puts '==================================================================='
|
31
|
+
$stderr.puts "AppOptics warning: Platform #{RUBY_PLATFORM} not yet supported."
|
32
|
+
$stderr.puts 'see: https://docs.appoptics.com/kb/apm_tracing/supported_platforms/'
|
33
|
+
$stderr.puts 'Tracing disabled.'
|
34
|
+
$stderr.puts 'Contact support@appoptics.com if this is unexpected.'
|
35
|
+
$stderr.puts '==================================================================='
|
36
|
+
end
|
37
|
+
rescue LoadError => e
|
38
|
+
unless ENV['RAILS_GROUP'] == 'assets' or ENV['IGNORE_APPOPTICS_WARNING']
|
39
|
+
$stderr.puts '=============================================================='
|
40
|
+
$stderr.puts 'Missing AppOpticsAPM libraries. Tracing disabled.'
|
41
|
+
$stderr.puts "Error: #{e.message}"
|
42
|
+
$stderr.puts 'See: https://docs.appoptics.com/kb/apm_tracing/ruby/'
|
43
|
+
$stderr.puts '=============================================================='
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
require 'appoptics_apm/config'
|
49
|
-
AppOpticsAPM::Config.load_config_file
|
50
|
-
|
51
47
|
require 'appoptics_apm/loading'
|
52
48
|
require 'appoptics_apm/legacy_method_profiling'
|
53
49
|
require 'appoptics_apm/method_profiling'
|
54
50
|
|
55
51
|
if AppOpticsAPM.loaded
|
52
|
+
# tracing mode is configured via config file but can only be set once we have oboe_metal loaded
|
53
|
+
AppOpticsAPM.set_tracing_mode(AppOpticsAPM::Config[:tracing_mode].to_sym)
|
56
54
|
require 'appoptics_apm/instrumentation'
|
57
55
|
|
58
56
|
# Frameworks
|
@@ -18,6 +18,9 @@ module AppOpticsAPM
|
|
18
18
|
#
|
19
19
|
# These are the lower level methods, please see AppOpticsAPM::SDK
|
20
20
|
# for the higher level methods
|
21
|
+
#
|
22
|
+
# If using these directly make sure to always match a start/end and entry/exit to
|
23
|
+
# avoid broken traces.
|
21
24
|
module Logging
|
22
25
|
@@ints_or_nil = [Integer, Float, NilClass, String]
|
23
26
|
@@ints_or_nil << Fixnum unless RUBY_VERSION >= '2.4'
|
@@ -73,9 +76,10 @@ module AppOpticsAPM
|
|
73
76
|
return AppOpticsAPM::Context.toString
|
74
77
|
end
|
75
78
|
|
76
|
-
opts.merge!(:
|
77
|
-
:
|
78
|
-
:
|
79
|
+
opts.merge!(:Spec => 'error',
|
80
|
+
:ErrorClass => exception.class.name,
|
81
|
+
:ErrorMsg => exception.message)
|
82
|
+
opts.merge!(:Backtrace => exception.backtrace.join("\r\n")) if exception.backtrace
|
79
83
|
|
80
84
|
exception.instance_variable_set(:@exn_logged, true)
|
81
85
|
log(layer, :error, opts)
|
@@ -125,6 +129,9 @@ module AppOpticsAPM
|
|
125
129
|
# end
|
126
130
|
#++
|
127
131
|
|
132
|
+
# This is a bit ugly, but here is the best place to reset the layer_op thread local var.
|
133
|
+
AppOpticsAPM.layer_op = nil unless AppOpticsAPM::Context.isValid
|
134
|
+
|
128
135
|
if AppOpticsAPM.sample?(opts.merge(:xtrace => xtrace))
|
129
136
|
# Yes, we're sampling this request
|
130
137
|
# Probablistic tracing of a subset of requests based off of
|
@@ -182,9 +189,6 @@ module AppOpticsAPM
|
|
182
189
|
def log_end(layer, opts = {}, event = nil)
|
183
190
|
return AppOpticsAPM::Context.toString unless AppOpticsAPM.tracing?
|
184
191
|
|
185
|
-
# Deal with the transaction name
|
186
|
-
opts[:TransactionName] = determine_transaction_name(layer, opts)
|
187
|
-
|
188
192
|
event ||= AppOpticsAPM::Context.createEvent
|
189
193
|
log_event(layer, :exit, event, opts)
|
190
194
|
ensure
|
@@ -212,7 +216,7 @@ module AppOpticsAPM
|
|
212
216
|
def log_entry(layer, opts = {}, op = nil)
|
213
217
|
return AppOpticsAPM::Context.toString unless AppOpticsAPM.tracing?
|
214
218
|
|
215
|
-
AppOpticsAPM.layer_op = op.to_sym if op
|
219
|
+
AppOpticsAPM.layer_op = (AppOpticsAPM.layer_op || []) << op.to_sym if op
|
216
220
|
log_event(layer, :entry, AppOpticsAPM::Context.createEvent, opts)
|
217
221
|
end
|
218
222
|
|
@@ -257,7 +261,8 @@ module AppOpticsAPM
|
|
257
261
|
def log_exit(layer, opts = {}, op = nil)
|
258
262
|
return AppOpticsAPM::Context.toString unless AppOpticsAPM.tracing?
|
259
263
|
|
260
|
-
AppOpticsAPM.layer_op
|
264
|
+
AppOpticsAPM.layer_op.pop if op && AppOpticsAPM.layer_op.is_a?(Array) && AppOpticsAPM.layer_op.last == op.to_sym
|
265
|
+
|
261
266
|
log_event(layer, :exit, AppOpticsAPM::Context.createEvent, opts)
|
262
267
|
end
|
263
268
|
|
@@ -306,25 +311,6 @@ module AppOpticsAPM
|
|
306
311
|
AppOpticsAPM::Context.toString
|
307
312
|
end
|
308
313
|
|
309
|
-
##
|
310
|
-
# Determine the transaction name to be set on the trace
|
311
|
-
#
|
312
|
-
# A transaction name set via the opts key `:TransactionName` takes precedence
|
313
|
-
# over a currently set custom transaction name. if neither are provided it
|
314
|
-
# returns `"custom_#{span}"`
|
315
|
-
#
|
316
|
-
# === Argument:
|
317
|
-
# * +opts+ (hash) the value of :TransactionName will be set as custom transaction name
|
318
|
-
#
|
319
|
-
# === Returns:
|
320
|
-
# (string) the current transaction name
|
321
|
-
#
|
322
|
-
def determine_transaction_name(span, opts = {})
|
323
|
-
opts[:TransactionName] ||= opts.delete('TransactionName')
|
324
|
-
AppOpticsAPM::API.set_transaction_name(opts[:TransactionName])
|
325
|
-
AppOpticsAPM.transaction_name || "custom-#{span}"
|
326
|
-
end
|
327
|
-
|
328
314
|
private
|
329
315
|
|
330
316
|
##
|