appoptics_apm 4.2.3 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -0
  3. data/.travis.yml +15 -12
  4. data/Gemfile +0 -1
  5. data/README.md +7 -38
  6. data/Rakefile +17 -1
  7. data/appoptics_apm.gemspec +2 -0
  8. data/{build_gems.sh → build_gem.sh} +1 -1
  9. data/build_gem_upload_to_packagecloud.sh +15 -0
  10. data/examples/SDK/01_basic_tracing.rb +1 -1
  11. data/ext/oboe_metal/src/VERSION +1 -1
  12. data/ext/oboe_metal/src/bson/bson.h +1 -2
  13. data/ext/oboe_metal/src/bson/platform_hacks.h +4 -4
  14. data/lib/appoptics_apm.rb +28 -30
  15. data/lib/appoptics_apm/api/logging.rb +13 -27
  16. data/lib/appoptics_apm/api/metrics.rb +25 -11
  17. data/lib/appoptics_apm/api/profiling.rb +6 -11
  18. data/lib/appoptics_apm/api/tracing.rb +3 -24
  19. data/lib/appoptics_apm/base.rb +7 -32
  20. data/lib/appoptics_apm/config.rb +26 -4
  21. data/lib/appoptics_apm/frameworks/grape.rb +10 -8
  22. data/lib/appoptics_apm/frameworks/padrino.rb +3 -0
  23. data/lib/appoptics_apm/frameworks/rails.rb +20 -42
  24. data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +4 -6
  25. data/lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb +1 -1
  26. data/lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb +1 -1
  27. data/lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb +1 -1
  28. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -9
  29. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
  30. data/lib/appoptics_apm/frameworks/sinatra.rb +4 -1
  31. data/lib/appoptics_apm/inst/bunny-client.rb +16 -18
  32. data/lib/appoptics_apm/inst/memcached.rb +6 -10
  33. data/lib/appoptics_apm/inst/moped.rb +1 -1
  34. data/lib/appoptics_apm/inst/rack.rb +13 -15
  35. data/lib/appoptics_apm/inst/sidekiq-worker.rb +1 -1
  36. data/lib/appoptics_apm/inst/typhoeus.rb +4 -2
  37. data/lib/appoptics_apm/loading.rb +1 -1
  38. data/lib/appoptics_apm/sdk.rb +48 -50
  39. data/lib/appoptics_apm/version.rb +1 -1
  40. data/lib/appoptics_apm/xtrace.rb +1 -1
  41. data/lib/oboe_metal.rb +13 -11
  42. data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +45 -7
  43. metadata +5 -16
  44. data/.codeclimate.yml +0 -43
  45. data/Dockerfile +0 -41
  46. data/Dockerfile_alpine +0 -66
  47. data/Dockerfile_test +0 -73
  48. data/config/initializers/.keep +0 -0
  49. data/docker-compose.yml +0 -95
  50. data/ext/oboe_metal/tests/test.rb +0 -11
  51. data/lib/appoptics_apm/frameworks/rails/inst/action_controller2.rb +0 -61
  52. data/lib/appoptics_apm/frameworks/rails/inst/action_view_2x.rb +0 -56
  53. data/ruby_setup.sh +0 -49
  54. data/run_docker_build_gem_upload_to_packagecloud.sh +0 -20
  55. data/run_tests_docker.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 984f806c1810b83b4528e75fd4a4e7b48db4bfa7
4
- data.tar.gz: 77acebf5def90972f7bbaa165bdcb4fa5d603442
2
+ SHA256:
3
+ metadata.gz: f9cd8f06bd5c7b8d7b31daf27b9208a3e528ea3ee65f2cc8b9331eeb823f7e52
4
+ data.tar.gz: 2356b83ed28ad90de5e5daecdf54187e45b742c63be1c5e5835db0588ec257ec
5
5
  SHA512:
6
- metadata.gz: 1ddf576b6e8d1ee6d638064e9573bf2461fa34fde1140c9eb63eb193d7540e7d383865b9268d96d85285c932a4ebc33d5c6b7178dd2f1164c76e5c54dc9754f0
7
- data.tar.gz: bb28f4ca6696d843e9876c32eb277bff52198d90088a680f16468c1e675c1235b09eef5da5432e38ce6c695a01016defb06b92dc3fab0eaa98dfe9290d293d4f
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*
@@ -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
- # - gemfiles/rails32.gemfile # We currently are not supporting Rails 3.2
25
+ - gemfiles/rails52.gemfile
26
+ # - gemfiles/rails51.gemfile
26
27
  - gemfiles/rails42.gemfile
27
- - gemfiles/rails51.gemfile
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.3
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.png)](https://badge.fury.io/rb/appoptics_apm)
15
- [![Build Status](https://travis-ci.com/librato/ruby-appoptics.png?branch=master)](https://travis-ci.com/librato/ruby-appoptics)
16
- [![Code Climate](https://codeclimate.com/github/librato/ruby-appoptics.png)](https://codeclimate.com/github/librato/ruby-appoptics)
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 name has been changed to ruby-appoptics. Please update your github remotes with
19
- `git remote set-url origin git@github.com:librato/ruby-appoptics.git`._
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
- There are few caveats with the tests:
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 > fetchsource > compile.'
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.'
@@ -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')
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # builds the appoptics_apm gem for JRuby and MRI.
2
+ # builds the appoptics_apm gem for MRI.
3
3
 
4
4
  echo -e "\n=== building for MRI ===\n"
5
5
  export RBENV_VERSION=2.3.1
@@ -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
@@ -7,7 +7,7 @@
7
7
  # `bundle exec ruby 01_basic_tracing.rb`
8
8
 
9
9
  require 'appoptics_apm'
10
- unless AppopticsAPM::SDK.appoptics_ready(10_000)
10
+ unless AppopticsAPM::SDK.appoptics_ready?(10_000)
11
11
  puts "aborting!!! Agent not ready after 10 seconds"
12
12
  exit false
13
13
  end
@@ -1 +1 @@
1
- 3.0.2
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) ( memcpy(out, in, 8) )
55
- #define bson_big_endian32(out, in) ( memcpy(out, in, 4) )
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) ( memcpy(out, in, 8) )
58
- #define bson_little_endian32(out, in) ( memcpy(out, in, 4) )
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
@@ -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
- # If OboeHeroku is already defined then we are in a PaaS environment
18
- # with an alternate metal (see the oboe-heroku gem)
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
- begin
24
- if RUBY_PLATFORM == 'java'
25
- require '/usr/local/tracelytics/tracelyticsagent.jar'
26
- require 'joboe_metal'
27
- elsif RUBY_PLATFORM =~ /linux/
28
- require 'oboe_metal.so'
29
- require 'oboe_metal.rb' # sets AppOpticsAPM.loaded = true if successful
30
- else
31
- $stderr.puts '==================================================================='
32
- $stderr.puts "AppOptics warning: Platform #{RUBY_PLATFORM} not yet supported."
33
- $stderr.puts 'see: https://docs.appoptics.com/kb/apm_tracing/supported_platforms/'
34
- $stderr.puts 'Tracing disabled.'
35
- $stderr.puts 'Contact support@appoptics.com if this is unexpected.'
36
- $stderr.puts '==================================================================='
37
- end
38
- rescue LoadError
39
- unless ENV['RAILS_GROUP'] == 'assets' or ENV['IGNORE_APPOPTICS_WARNING']
40
- $stderr.puts '=============================================================='
41
- $stderr.puts 'Missing AppOpticsAPM libraries. Tracing disabled.'
42
- $stderr.puts 'See: https://docs.appoptics.com/kb/apm_tracing/ruby/'
43
- $stderr.puts '=============================================================='
44
- end
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!(:ErrorClass => exception.class.name,
77
- :ErrorMsg => exception.message,
78
- :Backtrace => exception.backtrace.join("\r\n")) if exception.backtrace
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 = nil if 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
  ##