appoptics_apm 4.10.1 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -156,4 +156,4 @@ if defined?(GRPC) && AppOpticsAPM::Config[:grpc_client][:enabled]
156
156
 
157
157
  end
158
158
  end
159
- end
159
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2020 SolarWinds, LLC.
2
+ # All rights reserved.
3
+
4
+ module AppOpticsAPM
5
+ module RackCacheContext
6
+
7
+ ###
8
+ # This adds a controller.action like transaction name for
9
+ # requests directly served from the cache without involving a controller.
10
+ # The resulting transaction name is `rack-cache.<cache-store>`,
11
+ # e.g. `rack-cache.memcached`
12
+ #
13
+ # It is not a full instrumentation, no span is added.
14
+ #
15
+ def call!(env)
16
+ metastore_type = begin
17
+ if options['rack-cache.metastore']
18
+ options['rack-cache.metastore'].match(/^([^\:]*)\:/)[1]
19
+ end || 'unknown_store'
20
+ rescue
21
+ 'unknown_store'
22
+ end
23
+
24
+ env['appoptics_apm.action'] = metastore_type
25
+ env['appoptics_apm.controller'] = 'rack-cache'
26
+
27
+ super
28
+ end
29
+ end
30
+ end
31
+
32
+ if AppOpticsAPM::Config[:rack_cache][:transaction_name] && defined?(Rack::Cache::Context)
33
+ AppOpticsAPM.logger.info '[appoptics_apm/loading] Instrumenting rack_cache' if AppOpticsAPM::Config[:verbose]
34
+ Rack::Cache::Context.send(:prepend, ::AppOpticsAPM::RackCacheContext)
35
+ end
@@ -29,7 +29,7 @@ module AppOpticsAPM
29
29
  # end
30
30
  #
31
31
  # === Returns:
32
- # * true on success, false on failure
32
+ # * 0 on success, error code on failure
33
33
  #
34
34
  def increment_metric(name, count = 1, with_hostname = false, tags_kvs = {})
35
35
  return true unless AppOpticsAPM.loaded
@@ -62,7 +62,7 @@ module AppOpticsAPM
62
62
  # end
63
63
  #
64
64
  # === Returns:
65
- # * true on success, false on failure
65
+ # * 0 on success, error code on failure
66
66
  #
67
67
  def summary_metric(name, value, count = 1, with_hostname = false, tags_kvs = {})
68
68
  return true unless AppOpticsAPM.loaded
@@ -25,7 +25,7 @@ module AppOpticsAPM
25
25
  # * +exception+ - an exception, must respond to :message and :backtrace
26
26
  # * +opts+ - (optional) hash containing key/value pairs that will be reported with this span.
27
27
  #
28
- def log_exception(exception, opts)
28
+ def log_exception(exception, opts = {})
29
29
  AppOpticsAPM::API.log_exception(AppOpticsAPM.layer, exception, opts)
30
30
  end
31
31
 
@@ -300,7 +300,7 @@ module AppOpticsAPM
300
300
  end
301
301
 
302
302
  AppOpticsAPM::SDK.trace(span, report_kvs) do
303
- report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace(2) if backtrace
303
+ report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if backtrace
304
304
  send(without_appoptics, *args, &block)
305
305
  end
306
306
  end
@@ -311,7 +311,7 @@ module AppOpticsAPM
311
311
  elsif class_method
312
312
  klass.define_singleton_method(with_appoptics) do |*args, &block|
313
313
  AppOpticsAPM::SDK.trace(span, report_kvs) do
314
- report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace(2) if backtrace
314
+ report_kvs[:Backtrace] = AppOpticsAPM::API.backtrace if backtrace
315
315
  send(without_appoptics, *args, &block)
316
316
  end
317
317
  end
@@ -411,7 +411,7 @@ module AppOpticsAPM
411
411
  #
412
412
  # === Example:
413
413
  #
414
- # unless AppopticsAPM::SDK.appoptics_ready?(10_000)
414
+ # unless AppOpticsAPM::SDK.appoptics_ready?(10_000)
415
415
  # Logger.info "AppOptics not ready after 10 seconds, no metrics will be sent"
416
416
  # end
417
417
  #
@@ -424,7 +424,7 @@ module AppOpticsAPM
424
424
  # OBOE_SERVER_RESPONSE_LIMIT_EXCEEDED 3
425
425
  # OBOE_SERVER_RESPONSE_INVALID_API_KEY 4
426
426
  # OBOE_SERVER_RESPONSE_CONNECT_ERROR 5
427
- AppopticsAPM::Context.isReady(wait_milliseconds) == 1
427
+ AppOpticsAPM::Context.isReady(wait_milliseconds) == 1
428
428
  end
429
429
  end
430
430
 
@@ -64,4 +64,4 @@ module AppOpticsAPM
64
64
 
65
65
  end
66
66
  end
67
- end
67
+ end
@@ -54,7 +54,8 @@ module AppOpticsAPM
54
54
  if ENV.key?('TRAVIS_PSQL_PASS')
55
55
  ENV['DATABASE_URL'] = "postgresql://postgres:#{ENV['TRAVIS_PSQL_PASS']}@127.0.0.1:5432/travis_ci_test"
56
56
  elsif ENV.key?('DOCKER_PSQL_PASS')
57
- ENV['DATABASE_URL'] = "postgresql://docker:#{ENV['DOCKER_PSQL_PASS']}@127.0.0.1:5432/travis_ci_test"
57
+ ENV['DATABASE_URL'] = "postgresql://docker:#{ENV['DOCKER_PSQL_PASS']}@#{ENV['PSQL_HOST']}:5432/travis_ci_test"
58
+ # ENV['DATABASE_URL'] = "postgresql://postgres@#{ENV['PSQL_HOST']}:5432/travis_ci_test"
58
59
  else
59
60
  ENV['DATABASE_URL'] = 'postgresql://postgres@127.0.0.1:5432/travis_ci_test'
60
61
  end
@@ -7,8 +7,8 @@ module AppOpticsAPM
7
7
  # appoptics_apm.gemspec during gem build process
8
8
  module Version
9
9
  MAJOR = 4 # breaking,
10
- MINOR = 10 # feature,
11
- PATCH = 1 # fix => BFF
10
+ MINOR = 12 # feature,
11
+ PATCH = 0 # fix => BFF
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
14
14
  end
@@ -5,7 +5,7 @@ require 'thread'
5
5
 
6
6
  # Disable docs and Camelcase warns since we're implementing
7
7
  # an interface here. See OboeBase for details.
8
- # rubocop:disable Style/Documentation, Style/MethodName
8
+ # rubocop:disable Style/Documentation, Naming/MethodName
9
9
  module AppOpticsAPM
10
10
  extend AppOpticsAPMBase
11
11
  include Oboe_metal
@@ -20,26 +20,28 @@ module AppOpticsAPM
20
20
 
21
21
  private
22
22
 
23
- def print_header
24
- say ""
25
- say shell.set_color "Welcome to the AppOpticsAPM Ruby instrumentation setup.", :green, :bold
26
- say ""
27
- say shell.set_color "Documentation Links", :magenta
28
- say "-------------------"
29
- say ""
30
- say "AppOpticsAPM Installation Overview:"
31
- say "http://docs.appoptics.solarwinds.com/AppOpticsAPM/install-instrumentation.html"
32
- say ""
33
- say "More information on instrumenting Ruby applications can be found here:"
34
- say "http://docs.appoptics.solarwinds.com/Instrumentation/ruby.html#installing-ruby-instrumentation"
35
- end
36
-
37
- def print_footer
38
- say ""
39
- say "You can change configuration values in the future by modifying config/initializers/appoptics_apm.rb"
40
- say ""
41
- say "Thanks! Creating the AppOpticsAPM initializer..."
42
- say ""
43
- end
23
+ # rubocop:disable Metrics/MethodLength
24
+ def print_header
25
+ say ""
26
+ say shell.set_color "Welcome to the AppOpticsAPM Ruby instrumentation setup.", :green, :bold
27
+ say ""
28
+ say shell.set_color "Documentation Links", :magenta
29
+ say "-------------------"
30
+ say ""
31
+ say "AppOpticsAPM Installation Overview:"
32
+ say "http://docs.appoptics.solarwinds.com/AppOpticsAPM/install-instrumentation.html"
33
+ say ""
34
+ say "More information on instrumenting Ruby applications can be found here:"
35
+ say "http://docs.appoptics.solarwinds.com/Instrumentation/ruby.html#installing-ruby-instrumentation"
36
+ end
37
+ # rubocop:enable Metrics/MethodLength
38
+
39
+ def print_footer
40
+ say ""
41
+ say "You can change configuration values in the future by modifying config/initializers/appoptics_apm.rb"
42
+ say ""
43
+ say "Thanks! Creating the AppOpticsAPM initializer..."
44
+ say ""
45
+ end
44
46
  end
45
47
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # AppOpticsAPM Initializer (for the appoptics_apm gem)
2
4
  # https://www.appoptics.com/
3
5
  #
@@ -136,7 +138,36 @@ if defined?(AppOpticsAPM::Config)
136
138
  #
137
139
  AppOpticsAPM::Config[:dnt_regexp] = '\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|otf|eot|ttf|woff|woff2|svg|less)(\?.+){0,1}$'
138
140
  AppOpticsAPM::Config[:dnt_opts] = Regexp::IGNORECASE
141
+
139
142
  #
143
+ # GraphQL
144
+ #
145
+ # Enable tracing for GraphQL.
146
+ # (true | false, default: true)
147
+ AppOpticsAPM::Config[:graphql][:enabled] = true
148
+ # Replace query arguments with a '?' when sent with a trace.
149
+ # (true | false, default: true)
150
+ AppOpticsAPM::Config[:graphql][:sanitize] = true
151
+ # Remove comments from queries when sent with a trace.
152
+ # (true | false, default: true)
153
+ AppOpticsAPM::Config[:graphql][:remove_comments] = true
154
+ # Create a transaction name by combining
155
+ # "query" or "mutation" with the first word of the query.
156
+ # This overwrites the default transaction name, which is a combination of
157
+ # controller + action and would be the same for all graphql queries.
158
+ # (true | false, default: true)
159
+ AppOpticsAPM::Config[:graphql][:transaction_name] = true
160
+
161
+ #
162
+ # Rack::Cache
163
+ #
164
+ # Create a transaction name like `rack-cache.<cache-store>`,
165
+ # e.g. `rack-cache.memcached`
166
+ # This can reduce the number of transaction names, when many requests are
167
+ # served directly from the cache without hitting a controller action.
168
+ # When set to `false` the path will be used for the transaction name.
169
+ #
170
+ AppOpticsAPM::Config[:rack_cache] = { transaction_name: true }
140
171
 
141
172
  #
142
173
  # Transaction Settings
@@ -164,21 +195,20 @@ if defined?(AppOpticsAPM::Config)
164
195
  #
165
196
  AppOpticsAPM::Config[:transaction_settings] = {
166
197
  url: [
167
- # {
168
- # extensions: %w['long_job'],
169
- # tracing: :disabled
170
- # },
171
- # {
172
- # regexp: '^.*\/long_job\/.*$',
173
- # opts: Regexp::IGNORECASE,
174
- # tracing: :disabled
175
- # },
176
- # {
177
- # regexp: /batch/,
178
- # }
198
+ # {
199
+ # extensions: %w['long_job'],
200
+ # tracing: :disabled
201
+ # },
202
+ # {
203
+ # regexp: '^.*\/long_job\/.*$',
204
+ # opts: Regexp::IGNORECASE,
205
+ # tracing: :disabled
206
+ # },
207
+ # {
208
+ # regexp: /batch/,
209
+ # }
179
210
  ]
180
211
  }
181
- #
182
212
 
183
213
  #
184
214
  # Blacklist urls
@@ -192,7 +222,6 @@ if defined?(AppOpticsAPM::Config)
192
222
  # Example: AppOpticsAPM::Config[:blacklist] = ['google.com']
193
223
  #
194
224
  AppOpticsAPM::Config[:blacklist] = []
195
- #
196
225
 
197
226
  #
198
227
  # Rails Exception Logging
@@ -203,7 +232,6 @@ if defined?(AppOpticsAPM::Config)
203
232
  # report all raised exceptions regardless.
204
233
  #
205
234
  AppOpticsAPM::Config[:report_rescued_errors] = false
206
- #
207
235
 
208
236
  #
209
237
  # EC2 Metadata Fetching Timeout
@@ -215,7 +243,6 @@ if defined?(AppOpticsAPM::Config)
215
243
  #
216
244
  AppOpticsAPM::Config[:ec2_metadata_timeout] = 1000
217
245
 
218
-
219
246
  #############################################
220
247
  ## SETTINGS FOR INDIVIDUAL GEMS/FRAMEWORKS ##
221
248
  #############################################
@@ -238,7 +265,6 @@ if defined?(AppOpticsAPM::Config)
238
265
  #
239
266
  AppOpticsAPM::Config[:bunnyconsumer][:controller] = :app_id
240
267
  AppOpticsAPM::Config[:bunnyconsumer][:action] = :type
241
- #
242
268
 
243
269
  #
244
270
  # Enabling/Disabling Instrumentation
@@ -282,7 +308,6 @@ if defined?(AppOpticsAPM::Config)
282
308
  AppOpticsAPM::Config[:sidekiqworker][:enabled] = true
283
309
  AppOpticsAPM::Config[:sinatra][:enabled] = true
284
310
  AppOpticsAPM::Config[:typhoeus][:enabled] = true
285
- #
286
311
 
287
312
  #
288
313
  # Argument logging
@@ -305,7 +330,6 @@ if defined?(AppOpticsAPM::Config)
305
330
  AppOpticsAPM::Config[:sidekiqclient][:log_args] = true
306
331
  AppOpticsAPM::Config[:sidekiqworker][:log_args] = true
307
332
  AppOpticsAPM::Config[:typhoeus][:log_args] = true
308
- #
309
333
 
310
334
  #
311
335
  # Enabling/Disabling Backtrace Collection
Binary file
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.10.1
4
+ version: 4.12.0
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-11-07 00:00:00.000000000 Z
13
+ date: 2020-06-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -30,82 +30,26 @@ dependencies:
30
30
  name: no_proxy_fix
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: 0.1.2
36
33
  - - ">="
37
34
  - !ruby/object:Gem::Version
38
35
  version: 0.1.2
39
- type: :runtime
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- requirements:
43
36
  - - "~>"
44
37
  - !ruby/object:Gem::Version
45
38
  version: 0.1.2
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 0.1.2
49
- - !ruby/object:Gem::Dependency
50
- name: rake
51
- requirement: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 0.9.0
56
- type: :development
57
- prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 0.9.0
63
- - !ruby/object:Gem::Dependency
64
- name: byebug
65
- requirement: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 8.0.0
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 8.0.0
77
- - !ruby/object:Gem::Dependency
78
- name: minitest-hooks
79
- requirement: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: 1.5.0
84
- type: :development
39
+ type: :runtime
85
40
  prerelease: false
86
41
  version_requirements: !ruby/object:Gem::Requirement
87
42
  requirements:
88
43
  - - ">="
89
44
  - !ruby/object:Gem::Version
90
- version: 1.5.0
91
- - !ruby/object:Gem::Dependency
92
- name: benchmark-ips
93
- requirement: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: 2.7.2
98
- type: :development
99
- prerelease: false
100
- version_requirements: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
45
+ version: 0.1.2
46
+ - - "~>"
103
47
  - !ruby/object:Gem::Version
104
- version: 2.7.2
48
+ version: 0.1.2
105
49
  description: 'Automatic tracing and metrics for Ruby applications. Get started at
106
50
  appoptics.com. @AppOptics
107
51
 
108
- '
52
+ '
109
53
  email: support@appoptics.com
110
54
  executables:
111
55
  - appoptics_apm_config
@@ -119,16 +63,18 @@ files:
119
63
  - ".gitignore"
120
64
  - ".rubocop.yml"
121
65
  - ".travis.yml"
66
+ - ".travis/bundle.sh"
122
67
  - ".yardopts"
123
68
  - CHANGELOG.md
124
69
  - CONFIG.md
125
70
  - Gemfile
126
71
  - LICENSE
127
72
  - README.md
73
+ - app/assets/config/manifest.js
128
74
  - appoptics_apm.gemspec
129
75
  - bin/appoptics_apm_config
130
- - examples/SDK/01_basic_tracing.rb
131
- - examples/carrying_context.rb
76
+ - examples/sdk_examples.rb
77
+ - ext/.vscode/launch.json
132
78
  - ext/oboe_metal/README.md
133
79
  - ext/oboe_metal/extconf.rb
134
80
  - ext/oboe_metal/lib/.keep
@@ -136,6 +82,7 @@ files:
136
82
  - ext/oboe_metal/src/VERSION
137
83
  - ext/oboe_metal/src/bson/bson.h
138
84
  - ext/oboe_metal/src/bson/platform_hacks.h
85
+ - ext/oboe_metal/src/function_profiler.hpp
139
86
  - ext/oboe_metal/src/oboe.h
140
87
  - ext/oboe_metal/src/oboe.hpp
141
88
  - ext/oboe_metal/src/oboe_debug.h
@@ -176,6 +123,7 @@ files:
176
123
  - lib/appoptics_apm/inst/em-http-request.rb
177
124
  - lib/appoptics_apm/inst/excon.rb
178
125
  - lib/appoptics_apm/inst/faraday.rb
126
+ - lib/appoptics_apm/inst/graphql.rb
179
127
  - lib/appoptics_apm/inst/grpc_client.rb
180
128
  - lib/appoptics_apm/inst/grpc_server.rb
181
129
  - lib/appoptics_apm/inst/http.rb
@@ -188,6 +136,7 @@ files:
188
136
  - lib/appoptics_apm/inst/mongo2.rb
189
137
  - lib/appoptics_apm/inst/moped.rb
190
138
  - lib/appoptics_apm/inst/rack.rb
139
+ - lib/appoptics_apm/inst/rack_cache.rb
191
140
  - lib/appoptics_apm/inst/redis.rb
192
141
  - lib/appoptics_apm/inst/resque.rb
193
142
  - lib/appoptics_apm/inst/rest-client.rb
@@ -222,10 +171,11 @@ files:
222
171
  - lib/oboe_metal.rb
223
172
  - lib/rails/generators/appoptics_apm/install_generator.rb
224
173
  - lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb
174
+ - lib/rb_appoptics_apm.so
225
175
  - yardoc_frontpage.md
226
176
  homepage: https://www.appoptics.com/
227
177
  licenses:
228
- - Librato Open License, Version 1.0
178
+ - Librato Open License, Version 1.0, https://bit.ly/2Kmm0mN
229
179
  metadata:
230
180
  changelog_uri: https://github.com/appoptics/appoptics-apm-ruby/releases
231
181
  documentation_uri: https://docs.appoptics.com/kb/apm_tracing/ruby/
@@ -246,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
196
  - !ruby/object:Gem::Version
247
197
  version: '0'
248
198
  requirements: []
249
- rubyforge_project:
250
- rubygems_version: 2.6.11
199
+ rubygems_version: 3.0.3
251
200
  signing_key:
252
201
  specification_version: 4
253
202
  summary: AppOptics APM performance instrumentation gem for Ruby