appoptics_apm 4.10.1 → 4.12.0

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 (37) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +27 -6
  4. data/.travis.yml +22 -43
  5. data/.travis/bundle.sh +9 -0
  6. data/Gemfile +31 -22
  7. data/app/assets/config/manifest.js +1 -0
  8. data/appoptics_apm.gemspec +13 -12
  9. data/examples/sdk_examples.rb +142 -0
  10. data/ext/.vscode/launch.json +20 -0
  11. data/ext/oboe_metal/extconf.rb +6 -2
  12. data/ext/oboe_metal/src/VERSION +1 -1
  13. data/ext/oboe_metal/src/function_profiler.hpp +160 -0
  14. data/lib/appoptics_apm/api/logging.rb +6 -2
  15. data/lib/appoptics_apm/api/metrics.rb +3 -1
  16. data/lib/appoptics_apm/api/util.rb +5 -7
  17. data/lib/appoptics_apm/config.rb +10 -9
  18. data/lib/appoptics_apm/frameworks/grape.rb +3 -2
  19. data/lib/appoptics_apm/frameworks/padrino.rb +1 -1
  20. data/lib/appoptics_apm/frameworks/rails.rb +7 -1
  21. data/lib/appoptics_apm/frameworks/sinatra.rb +1 -1
  22. data/lib/appoptics_apm/inst/graphql.rb +240 -0
  23. data/lib/appoptics_apm/inst/grpc_client.rb +1 -1
  24. data/lib/appoptics_apm/inst/rack_cache.rb +35 -0
  25. data/lib/appoptics_apm/sdk/custom_metrics.rb +2 -2
  26. data/lib/appoptics_apm/sdk/logging.rb +1 -1
  27. data/lib/appoptics_apm/sdk/tracing.rb +4 -4
  28. data/lib/appoptics_apm/support/transaction_metrics.rb +1 -1
  29. data/lib/appoptics_apm/test.rb +2 -1
  30. data/lib/appoptics_apm/version.rb +2 -2
  31. data/lib/oboe_metal.rb +1 -1
  32. data/lib/rails/generators/appoptics_apm/install_generator.rb +23 -21
  33. data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +43 -19
  34. data/lib/rb_appoptics_apm.so +0 -0
  35. metadata +17 -68
  36. data/examples/SDK/01_basic_tracing.rb +0 -68
  37. data/examples/carrying_context.rb +0 -220
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7e70295e3dc49a39e001776c90ae399d1c1ee522
4
- data.tar.gz: bc03b3d467a18370ce889b6c66228172a41efd5c
2
+ SHA256:
3
+ metadata.gz: 7a652aaa478b98230f9f924d9b8aaf98c36d532dd078e66fe2f123c53d0b871e
4
+ data.tar.gz: dff2fd57dfab08035c3a3f0af29b9cf41ebf0df486fe5e2ce93db5fa9ecef306
5
5
  SHA512:
6
- metadata.gz: f9d957a9d608fd1c3e3499125c96784b9767485934666986c8ecc1ca6befe89d870eb67b087887d5e6caf274452522e52c70dd773bf624a3144c225334688fe8
7
- data.tar.gz: 01e0625d7242ea1717d5264e65ab3b53df8f4e534e08ba7c67e6959a1e0478d81cdc2dcb6c08d7361008bdf78dbfd962879a59e0fd2ce3302d5c4e9e38e57d1a
6
+ metadata.gz: 187b9e776b1a976e12aa704cb8c1d894a8cd428b8e7702ed2871efd451d5d8127a7d02a1dd6461d87d3077c9348ec1334baaff5adc28e871ee67ae97d130632b
7
+ data.tar.gz: f7b555c14f9456c7a7a565003c48092104eed3c8f54d5c705e0abde35e33fc2e56748ddb7b6452729da5fa04dbad36c408f8fe9b2c58866261d3cecc9f532163
data/.gitignore CHANGED
@@ -32,3 +32,4 @@ scrap*
32
32
  *.code-workspace
33
33
  .irb_history
34
34
  .bundle/
35
+ /builds/
@@ -1,8 +1,29 @@
1
- Metrics/LineLength:
2
- Max: 120
1
+ Style/StringLiterals:
2
+ Description: 'Checks if uses of quotes match the configured preference.'
3
+ StyleGuide: '#consistent-string-literals'
4
+ Enabled: false
3
5
 
4
- Style/HashSyntax:
5
- EnforcedStyle: hash_rockets
6
+ Layout/LineLength:
7
+ Description: 'Limit lines to 80 characters.'
8
+ Enabled: false
6
9
 
7
- Layout/TrailingWhitespace:
8
- Enabled: false
10
+ Naming/VariableNumber:
11
+ Description: 'Use the configured style when numbering variables.'
12
+ Enabled: false
13
+
14
+ Style/FrozenStringLiteralComment:
15
+ Description: >-
16
+ Add the frozen_string_literal comment to the top of files
17
+ to help transition to frozen string literals by default.
18
+ Enabled: false
19
+
20
+ Style/Documentation:
21
+ Description: 'Document classes and non-namespace modules.'
22
+ Enabled: false
23
+
24
+ Style/WordArray:
25
+ EnforcedStyle: brackets
26
+
27
+ Metrics/BlockLength:
28
+ Exclude:
29
+ - test/*/*_test.rb
@@ -8,14 +8,13 @@ cache:
8
8
  env:
9
9
  - DBTYPE=postgresql
10
10
  - DBTYPE=mysql2
11
- - DBTYPE=mysql
12
11
 
13
12
  rvm:
13
+ - 2.7.0
14
14
  - 2.6.4
15
15
  - 2.5.5
16
16
  - 2.4.5
17
- - 2.7.0-preview2
18
- # - ruby-head
17
+ - ruby-head
19
18
  # - jruby-9.0.5.0
20
19
 
21
20
  gemfile:
@@ -34,42 +33,14 @@ matrix:
34
33
  exclude:
35
34
  - rvm: ruby-head
36
35
  gemfile: gemfiles/rails42.gemfile
37
- - rvm: 2.7.0-preview2
36
+ - rvm: 2.7.0
38
37
  gemfile: gemfiles/rails42.gemfile
39
38
  - rvm: 2.6.4
40
39
  gemfile: gemfiles/rails42.gemfile
41
40
  - rvm: 2.4.5
42
41
  gemfile: gemfiles/rails60.gemfile
43
-
44
- - rvm: ruby-head
45
- env: DBTYPE=mysql
46
- - rvm: 2.7.0-preview2
47
- env: DBTYPE=mysql
48
- - rvm: 2.6.4
49
- env: DBTYPE=mysql
50
- - rvm: 2.5.5
51
- env: DBTYPE=mysql
52
- - rvm: 2.4.5
53
- env: DBTYPE=mysql
54
-
55
- - gemfile: gemfiles/unit.gemfile
56
- env: DBTYPE=mysql
57
- - gemfile: gemfiles/noop.gemfile
58
- env: DBTYPE=mysql
59
- - gemfile: gemfiles/libraries.gemfile
60
- env: DBTYPE=mysql
61
- - gemfile: gemfiles/instrumentation_mocked.gemfile
62
- env: DBTYPE=mysql
63
- - gemfile: gemfiles/instrumentation_mocked_oldgems.gemfile
64
- env: DBTYPE=mysql
65
- - gemfile: gemfiles/frameworks.gemfile
66
- env: DBTYPE=mysql
67
- - gemfile: gemfiles/rails52.gemfile
68
- env: DBTYPE=mysql
69
- - gemfile: gemfiles/rails60.gemfile
70
- env: DBTYPE=mysql
71
- - gemfile: gemfiles/delayed_job.gemfile
72
- env: DBTYPE=mysql
42
+ - rvm: 2.4.5 # excluding because of new sprockets version (4.0.0)
43
+ gemfile: gemfiles/rails52.gemfile
73
44
 
74
45
  - gemfile: gemfiles/unit.gemfile
75
46
  env: DBTYPE=mysql2
@@ -87,9 +58,9 @@ matrix:
87
58
  env: DBTYPE=mysql2
88
59
  allow_failures:
89
60
  - rvm: ruby-head
90
- - rvm: 2.7.0-preview2
91
61
 
92
- # FIXME: Figure out if this is still an issue when reviewing cassandra test setup
62
+ # FIXME: No cassandra tests for now
63
+ # ____ Figure out if this is still an issue when reviving cassandra
93
64
  # Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484
94
65
  # Updated Cassandra: https://github.com/travis-ci/travis-ci/issues/1650
95
66
 
@@ -104,23 +75,31 @@ matrix:
104
75
  # - sudo service cassandra start
105
76
 
106
77
  install:
107
- - curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz
108
- - tar xzf swig-3.0.12.tar.gz
109
- - pushd swig-3.0.12
78
+ - curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-4.0.2/swig-4.0.2.tar.gz
79
+ - tar xzf swig-4.0.2.tar.gz
80
+ - pushd swig-4.0.2
110
81
  - ./configure && make && sudo make install
111
82
  - popd
112
83
 
84
+ # use swig from git in case fixes haven't been released
85
+ # - git clone https://github.com/swig/swig.git
86
+ # - pushd swig
87
+ # - ./autogen.sh
88
+ # - ./configure && make && sudo make install
89
+ # - popd
90
+
113
91
  before_script:
114
92
  - export APPOPTICS_GEM_TEST=true
115
93
  - export APPOPTICS_REPORTER=file
116
94
  - export APPOPTICS_COLLECTOR=/tmp/appoptics_traces.bson
117
95
  - export APPOPTICS_REPORTER_FILE_SINGLE=false
118
- - export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
119
- - export APPOPTICS_TOKEN_BUCKET_RATE=1000
96
+ # - export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
97
+ # - export APPOPTICS_TOKEN_BUCKET_RATE=1000
120
98
  - export APPOPTICS_FROM_S3=true
121
99
 
122
- - bundle update --jobs=3 --retry=3
123
- - bundle exec rake clean fetch compile
100
+ # - bundle update --jobs=3 --retry=3
101
+ - ./.travis/bundle.sh
102
+ - bundle exec rake distclean fetch compile
124
103
  - psql -c 'create database travis_ci_test;' -U postgres
125
104
  - mysql -e 'create database travis_ci_test;'
126
105
  - redis-server --requirepass secret_pass &
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ if [[ $BUNDLE_GEMFILE == *"gemfiles/frameworks.gemfile"* ]]
4
+ then
5
+ gem install bundler -v 1.17.3
6
+ bundle _1.17.3_ update --jobs=3 --retry=3
7
+ else
8
+ bundle update --jobs=3 --retry=3
9
+ fi
data/Gemfile CHANGED
@@ -1,29 +1,38 @@
1
1
  source 'https://rubygems.org'
2
- gem 'rake'
2
+
3
+ # this Gemfile is very minimal
4
+ # use rake commands or gemfiles in the gemfiles directory for testing
5
+
6
+ gem 'rake', '>= 0.9.0'
3
7
 
4
8
  group :development, :test do
5
- gem 'minitest'
6
- gem 'minitest-reporters', '< 1.0.18'
7
- gem 'minitest-debugger', :require => false
8
- gem 'rack-test'
9
- gem 'puma'
10
- gem 'bson'
11
- gem 'webmock' if RUBY_VERSION >= '2.0.0'
12
- gem 'mocha'
13
- gem 'rubocop', require: false
14
- gem 'ruby-prof'
15
- gem 'benchmark-ips'
16
- gem 'ruby-debug', :platforms => :jruby
17
- gem 'debugger', :platform => :mri_19
18
- gem 'byebug'
19
- gem 'get_process_mem'
20
- gem 'memory_profiler'
9
+ # gem 'benchmark-ips', '>= 2.7.2'
10
+ # gem 'bson'
11
+ gem 'byebug', '>= 8.0.0'
12
+ # gem 'debugger', :platform => :mri_19
13
+ # gem 'get_process_mem'
14
+ gem 'irb', '>= 1.0.0' # if RUBY_VERSION >= '2.6.0'
15
+ # gem 'memory_profiler'
16
+ # gem 'minitest'
17
+ # gem 'minitest-debugger', :require => false
18
+ # gem 'minitest-focus', '>=1.1.2'
19
+ # gem 'minitest-hooks', '>= 1.5.0'
20
+ # gem 'minitest-reporters', '< 1.0.18'
21
+ # gem 'mocha'
22
+ # gem 'puma'
23
+ # gem 'rack-test'
24
+ # gem 'rubocop', require: false
25
+ # gem 'ruby-debug', :platforms => :jruby
26
+ # gem 'ruby-prof'
27
+ # gem 'simplecov', '>= 0.16.0'
28
+ # gem 'simplecov-console'
29
+ # gem 'webmock' if RUBY_VERSION >= '2.0.0'
21
30
 
22
- if defined?(JRUBY_VERSION)
23
- gem 'sinatra', :require => false
24
- else
25
- gem 'sinatra'
26
- end
31
+ # if defined?(JRUBY_VERSION)
32
+ # gem 'sinatra', :require => false
33
+ # else
34
+ # gem 'sinatra'
35
+ # end
27
36
  end
28
37
 
29
38
  gemspec
@@ -0,0 +1 @@
1
+ {}
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.version = AppOpticsAPM::Version::STRING
7
7
  s.date = Time.now.strftime('%Y-%m-%d')
8
8
 
9
- s.license = "Librato Open License, Version 1.0"
9
+ s.license = "Librato Open License, Version 1.0, https://bit.ly/2Kmm0mN"
10
10
 
11
11
  s.authors = ["Maia Engeli", "Peter Giacomo Lombardo", "Spiros Eliopoulos"]
12
12
  s.email = %q{support@appoptics.com}
@@ -42,20 +42,21 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
42
42
 
43
43
  s.extensions = ['ext/oboe_metal/extconf.rb'] unless defined?(JRUBY_VERSION)
44
44
 
45
- s.add_runtime_dependency('json', '>= 0')
45
+ s.add_runtime_dependency('json')
46
46
  s.add_runtime_dependency('no_proxy_fix', '~> 0.1.2', '>= 0.1.2')
47
47
 
48
48
  # Development dependencies used in gem development & testing
49
- s.add_development_dependency('rake', '>= 0.9.0')
50
- s.add_development_dependency('simplecov', '>= 0.16.0') if ENV["SIMPLECOV_COVERAGE"]
51
- s.add_development_dependency('simplecov-console', '>= 0.4.0') if ENV["SIMPLECOV_COVERAGE"]
52
- s.add_development_dependency('irb', '>= 1.0.0') if RUBY_VERSION >= '2.6.0'
53
-
54
- unless defined?(JRUBY_VERSION)
55
- s.add_development_dependency('byebug', '>= 8.0.0')
56
- s.add_development_dependency('minitest-hooks', '>= 1.5.0')
57
- s.add_development_dependency('benchmark-ips', '>= 2.7.2')
58
- end
49
+ # s.add_development_dependency('rake', '>= 0.9.0')
50
+ # s.add_development_dependency('simplecov', '>= 0.16.0') if ENV["SIMPLECOV_COVERAGE"]
51
+ # s.add_development_dependency('simplecov-console', '>= 0.4.0') if ENV["SIMPLECOV_COVERAGE"]
52
+ # s.add_development_dependency('irb', '>= 1.0.0') if RUBY_VERSION >= '2.6.0'
53
+ #
54
+ # unless defined?(JRUBY_VERSION)
55
+ # s.add_development_dependency('byebug', '>= 8.0.0')
56
+ # s.add_development_dependency('minitest-hooks', '>= 1.5.0')
57
+ # s.add_development_dependency('minitest-focus', '>=1.1.2')
58
+ # s.add_development_dependency('benchmark-ips', '>= 2.7.2')
59
+ # end
59
60
 
60
61
  s.required_ruby_version = '>= 2.4.0'
61
62
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -0,0 +1,142 @@
1
+ # Copyright (c) 2020 SolarWinds, LLC.
2
+ # All rights reserved.
3
+
4
+ ###############################################################
5
+ # SDK EXAMPLES
6
+ ###############################################################
7
+ # The uses cases of the SDK include:
8
+ # - tracing a piece of your own code
9
+ # - tracing a method call of a gem that is not auto-instrumented
10
+ # by appoptics_apm
11
+ #
12
+ # SDK documentation:
13
+ # https://rubydoc.info/gems/appoptics_apm/AppOpticsAPM/SDK
14
+
15
+ ###############################################################
16
+ # Prerequisits
17
+ # export APPOPTICS_SERVICE_KEY=<API token>:<service_name>
18
+ # `bundle exec ruby sdk_examples.rb`
19
+ # 5 traced requests will show up at https://my.appoptics.com/
20
+ ###############################################################
21
+
22
+ require 'appoptics_apm'
23
+
24
+ unless AppOpticsAPM::SDK.appoptics_ready?(10_000)
25
+ puts "aborting!!! Agent not ready after 10 seconds"
26
+ exit false
27
+ end
28
+
29
+ ###############################################################
30
+ ### ADD A SPAN
31
+ ###############################################################
32
+ #
33
+ # AppOpticsAPM::SDK.trace()
34
+ # This method adds a span to a trace that has been started either
35
+ # by the auto-instrumentation of the gem handling incoming requests
36
+ # or the SDK method `start_trace`.
37
+ # If this method is called outside of the context of a started
38
+ # trace no spans will be created.
39
+ #
40
+ # The argument is the name for the span
41
+
42
+ AppOpticsAPM::SDK.trace('span_name') do
43
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
44
+ end
45
+
46
+ ###############################################################
47
+ # START A TRACE, ADD A SPAN, AND LOG AN INFO EVENT
48
+ ###############################################################
49
+ #
50
+ # AppOpticsAPM::SDK.start_trace()
51
+ # This method starts a trace. It is handy for background jobs,
52
+ # workers, or scripts, that are not part of a rack application
53
+
54
+ AppOpticsAPM::SDK.start_trace('outer_span') do
55
+ AppOpticsAPM::SDK.trace('first_child_span') do
56
+ [9, 6, 12, 2, 7, 1, 9, 3, 4, 14, 5, 8].sort
57
+ AppOpticsAPM::SDK.log_info({ some: :fancy, hash: :to, send: 1 })
58
+ end
59
+ end
60
+
61
+ ###############################################################
62
+ # LOG AN ERROR EVENT
63
+ ###############################################################
64
+ #
65
+ # AppOpticsAPM::SDK.log_exception()
66
+ # This method adds an error event to the trace, which will be
67
+ # displayed and counted as exception on the appoptics dashboard.
68
+
69
+ def do_raise
70
+ raise StandardError.new("oops")
71
+ end
72
+
73
+ AppOpticsAPM::SDK.start_trace('with_error') do
74
+ begin
75
+ do_raise
76
+ rescue => e
77
+ AppOpticsAPM::SDK.log_exception(e)
78
+ end
79
+ end
80
+
81
+ ###############################################################
82
+ # TRACE A METHOD
83
+ ###############################################################
84
+ #
85
+ # AppOpticsAPM::SDK.trace_method()
86
+ # This creates a span every time the defined method is run.
87
+ # The method can be of any (accessible) type (instance,
88
+ # singleton, private, protected etc.).
89
+
90
+ module ExampleModule
91
+ def self.do_sum(a, b)
92
+ a + b
93
+ end
94
+ end
95
+
96
+ AppOpticsAPM::SDK.trace_method(ExampleModule,
97
+ :do_sum,
98
+ { name: 'computation', backtrace: true },
99
+ { CustomKey: "some_info"})
100
+
101
+ AppOpticsAPM::SDK.start_trace('trace_a_method') do
102
+ ExampleModule.do_sum(1, 2)
103
+ ExampleModule.do_sum(3, 4)
104
+ end
105
+
106
+ ###############################################################
107
+ # SET A CUSTOM TRANSACTION NAME
108
+ ###############################################################
109
+ #
110
+ # AppOpticsAPM::SDK.set_transaction_name()
111
+ #
112
+ # this method can be called anytime after a trace has been started to add a
113
+ # custom name for the whole transaction.
114
+ # In case of a controller the trace is usually started in rack.
115
+
116
+ class FakeController
117
+ def create(params)
118
+ # @fake = fake.new(params.permit(:type, :title))
119
+ # @fake.save
120
+ AppOpticsAPM::SDK.set_transaction_name("fake.#{params[:type]}")
121
+ # redirect_to @fake
122
+ end
123
+ end
124
+
125
+ AppOpticsAPM::SDK.start_trace('set_transaction_name') do
126
+ FakeController.new.create(type: 'news')
127
+ end
128
+
129
+ ###############################################################
130
+ # LOG INJECTION OF TRACE_ID
131
+ ###############################################################
132
+ #
133
+ # AppOpticsAPM::SDK.current_trace
134
+ # This method creates an object with the current trace ID and
135
+ # helper methods to add the ID to logs for cross-referencing.
136
+
137
+ AppOpticsAPM::Config[:log_traceId] = :always
138
+
139
+ AppOpticsAPM::SDK.start_trace('log_trace_id') do
140
+ trace = AppOpticsAPM::SDK.current_trace
141
+ AppOpticsAPM.logger.warn "Some log message #{trace.for_log}"
142
+ end
@@ -0,0 +1,20 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "(lldb) Launch",
9
+ "type": "cppdbg",
10
+ "request": "launch",
11
+ "program": "enter program name, for example ${workspaceFolder}/a.out",
12
+ "args": [],
13
+ "stopAtEntry": false,
14
+ "cwd": "${workspaceFolder}",
15
+ "environment": [],
16
+ "externalConsole": false,
17
+ "MIMode": "lldb"
18
+ }
19
+ ]
20
+ }