appsignal 3.5.4-java → 3.5.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.semaphore/semaphore.yml +147 -9
  3. data/CHANGELOG.md +17 -0
  4. data/README.md +2 -0
  5. data/build_matrix.yml +5 -9
  6. data/ext/Rakefile +7 -1
  7. data/ext/agent.rb +27 -27
  8. data/gemfiles/redis-4.gemfile +5 -0
  9. data/gemfiles/redis-5.gemfile +6 -0
  10. data/lib/appsignal/cli/diagnose.rb +1 -1
  11. data/lib/appsignal/config.rb +9 -4
  12. data/lib/appsignal/environment.rb +24 -13
  13. data/lib/appsignal/event_formatter.rb +1 -1
  14. data/lib/appsignal/extension/jruby.rb +4 -3
  15. data/lib/appsignal/extension.rb +1 -1
  16. data/lib/appsignal/helpers/instrumentation.rb +7 -7
  17. data/lib/appsignal/helpers/metrics.rb +3 -3
  18. data/lib/appsignal/hooks/redis.rb +1 -0
  19. data/lib/appsignal/hooks/redis_client.rb +27 -0
  20. data/lib/appsignal/hooks.rb +3 -2
  21. data/lib/appsignal/integrations/hanami.rb +1 -1
  22. data/lib/appsignal/integrations/padrino.rb +1 -1
  23. data/lib/appsignal/integrations/railtie.rb +1 -1
  24. data/lib/appsignal/integrations/redis_client.rb +20 -0
  25. data/lib/appsignal/integrations/sidekiq.rb +1 -1
  26. data/lib/appsignal/integrations/sinatra.rb +1 -1
  27. data/lib/appsignal/minutely.rb +4 -4
  28. data/lib/appsignal/probes/gvl.rb +1 -1
  29. data/lib/appsignal/probes/helpers.rb +1 -1
  30. data/lib/appsignal/probes/mri.rb +1 -1
  31. data/lib/appsignal/probes/sidekiq.rb +5 -5
  32. data/lib/appsignal/rack/generic_instrumentation.rb +1 -1
  33. data/lib/appsignal/rack/rails_instrumentation.rb +2 -2
  34. data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -2
  35. data/lib/appsignal/rack/streaming_listener.rb +1 -1
  36. data/lib/appsignal/span.rb +2 -2
  37. data/lib/appsignal/transaction.rb +11 -11
  38. data/lib/appsignal/utils/deprecation_message.rb +2 -2
  39. data/lib/appsignal/version.rb +1 -1
  40. data/lib/appsignal.rb +37 -31
  41. data/spec/lib/appsignal/config_spec.rb +2 -2
  42. data/spec/lib/appsignal/hooks/activejob_spec.rb +1 -1
  43. data/spec/lib/appsignal/hooks/redis_client_spec.rb +222 -0
  44. data/spec/lib/appsignal/hooks/redis_spec.rb +98 -76
  45. data/spec/lib/appsignal/hooks_spec.rb +4 -4
  46. data/spec/lib/appsignal/integrations/railtie_spec.rb +2 -2
  47. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +3 -3
  48. data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
  49. data/spec/lib/appsignal/minutely_spec.rb +2 -2
  50. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +1 -1
  51. data/spec/lib/appsignal/transaction_spec.rb +4 -4
  52. data/spec/lib/appsignal_spec.rb +34 -32
  53. data/spec/spec_helper.rb +1 -1
  54. data/spec/support/helpers/config_helpers.rb +6 -2
  55. data/spec/support/helpers/dependency_helper.rb +9 -1
  56. data/spec/support/helpers/log_helpers.rb +2 -2
  57. metadata +7 -2
@@ -68,9 +68,9 @@ module Appsignal
68
68
  namespace = Appsignal::Transaction::HTTP_REQUEST
69
69
  request = ::Rack::Request.new(env)
70
70
  else
71
- logger.error "Unrecognized name '#{name}': names must start with " \
72
- "either 'perform_job' (for jobs and tasks) or 'process_action' " \
73
- "(for HTTP requests)"
71
+ internal_logger.error "Unrecognized name '#{name}': names must " \
72
+ "start with either 'perform_job' (for jobs and tasks) or " \
73
+ "'process_action' (for HTTP requests)"
74
74
  return yield
75
75
  end
76
76
 
@@ -228,8 +228,8 @@ module Appsignal
228
228
  return unless active?
229
229
 
230
230
  unless error.is_a?(Exception)
231
- logger.error "Appsignal.send_error: Cannot send error. The given " \
232
- "value is not an exception: #{error.inspect}"
231
+ internal_logger.error "Appsignal.send_error: Cannot send error. " \
232
+ "The given value is not an exception: #{error.inspect}"
233
233
  return
234
234
  end
235
235
  transaction = Appsignal::Transaction.new(
@@ -319,8 +319,8 @@ module Appsignal
319
319
  "Appsignal.set_error called on location: #{call_location}"
320
320
  end
321
321
  unless exception.is_a?(Exception)
322
- logger.error "Appsignal.set_error: Cannot set error. The given " \
323
- "value is not an exception: #{exception.inspect}"
322
+ internal_logger.error "Appsignal.set_error: Cannot set error. " \
323
+ "The given value is not an exception: #{exception.inspect}"
324
324
  return
325
325
  end
326
326
  return if !active? || !Appsignal::Transaction.current?
@@ -10,7 +10,7 @@ module Appsignal
10
10
  Appsignal::Utils::Data.generate(tags)
11
11
  )
12
12
  rescue RangeError
13
- Appsignal.logger
13
+ Appsignal.internal_logger
14
14
  .warn("Gauge value #{value} for key '#{key}' is too big")
15
15
  end
16
16
 
@@ -37,7 +37,7 @@ module Appsignal
37
37
  Appsignal::Utils::Data.generate(tags)
38
38
  )
39
39
  rescue RangeError
40
- Appsignal.logger
40
+ Appsignal.internal_logger
41
41
  .warn("Counter value #{value} for key '#{key}' is too big")
42
42
  end
43
43
 
@@ -48,7 +48,7 @@ module Appsignal
48
48
  Appsignal::Utils::Data.generate(tags)
49
49
  )
50
50
  rescue RangeError
51
- Appsignal.logger
51
+ Appsignal.internal_logger
52
52
  .warn("Distribution value #{value} for key '#{key}' is too big")
53
53
  end
54
54
  end
@@ -8,6 +8,7 @@ module Appsignal
8
8
 
9
9
  def dependencies_present?
10
10
  defined?(::Redis) &&
11
+ !defined?(::RedisClient) &&
11
12
  Appsignal.config &&
12
13
  Appsignal.config[:instrument_redis]
13
14
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ class Hooks
5
+ # @api private
6
+ class RedisClientHook < Appsignal::Hooks::Hook
7
+ register :redis_client
8
+
9
+ def dependencies_present?
10
+ defined?(::RedisClient) &&
11
+ Appsignal.config &&
12
+ Appsignal.config[:instrument_redis]
13
+ end
14
+
15
+ def install
16
+ require "appsignal/integrations/redis_client"
17
+ ::RedisClient::RubyConnection.prepend Appsignal::Integrations::RedisClientIntegration
18
+ Appsignal::Environment.report_enabled("redis")
19
+
20
+ return unless defined?(::RedisClient::HiredisConnection)
21
+
22
+ ::RedisClient::HiredisConnection.prepend Appsignal::Integrations::RedisClientIntegration
23
+ Appsignal::Environment.report_enabled("hiredis")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -32,12 +32,12 @@ module Appsignal
32
32
  return unless dependencies_present?
33
33
  return if installed?
34
34
 
35
- Appsignal.logger.debug("Installing #{name} hook")
35
+ Appsignal.internal_logger.debug("Installing #{name} hook")
36
36
  begin
37
37
  install
38
38
  @installed = true
39
39
  rescue => ex
40
- logger = Appsignal.logger
40
+ logger = Appsignal.internal_logger
41
41
  logger.error("Error while installing #{name} hook: #{ex}")
42
42
  logger.debug ex.backtrace.join("\n")
43
43
  end
@@ -103,6 +103,7 @@ require "appsignal/hooks/passenger"
103
103
  require "appsignal/hooks/puma"
104
104
  require "appsignal/hooks/rake"
105
105
  require "appsignal/hooks/redis"
106
+ require "appsignal/hooks/redis_client"
106
107
  require "appsignal/hooks/resque"
107
108
  require "appsignal/hooks/sequel"
108
109
  require "appsignal/hooks/shoryuken"
@@ -6,7 +6,7 @@ module Appsignal
6
6
  module Integrations
7
7
  module HanamiPlugin
8
8
  def self.init
9
- Appsignal.logger.debug("Loading Hanami integration")
9
+ Appsignal.internal_logger.debug("Loading Hanami integration")
10
10
 
11
11
  hanami_app_config = ::Hanami.app.config
12
12
  Appsignal.config = Appsignal::Config.new(
@@ -7,7 +7,7 @@ module Appsignal
7
7
  # @api private
8
8
  module PadrinoPlugin
9
9
  def self.init
10
- Appsignal.logger.debug("Loading Padrino (#{Padrino::VERSION}) integration")
10
+ Appsignal.internal_logger.debug("Loading Padrino (#{Padrino::VERSION}) integration")
11
11
 
12
12
  root = Padrino.mounted_root
13
13
  Appsignal.config = Appsignal::Config.new(root, Padrino.env)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Appsignal.logger.debug("Loading Rails (#{Rails.version}) integration")
3
+ Appsignal.internal_logger.debug("Loading Rails (#{Rails.version}) integration")
4
4
 
5
5
  require "appsignal/utils/rails_helper"
6
6
  require "appsignal/rack/rails_instrumentation"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module RedisClientIntegration
6
+ def write(command)
7
+ sanitized_command =
8
+ if command[0] == :eval
9
+ "#{command[1]}#{" ?" * (command.size - 3)}"
10
+ else
11
+ "#{command[0]}#{" ?" * (command.size - 1)}"
12
+ end
13
+
14
+ Appsignal.instrument "query.redis", @config.id, sanitized_command do
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -168,7 +168,7 @@ module Appsignal
168
168
  # Sidekiq issue #1761: in dev mode, it's possible to have jobs enqueued
169
169
  # which haven't been loaded into memory yet so the YAML can't be
170
170
  # loaded.
171
- Appsignal.logger.warn "Unable to load YAML: #{error.message}"
171
+ Appsignal.internal_logger.warn "Unable to load YAML: #{error.message}"
172
172
  default
173
173
  end
174
174
  end
@@ -3,7 +3,7 @@
3
3
  require "appsignal"
4
4
  require "appsignal/rack/sinatra_instrumentation"
5
5
 
6
- Appsignal.logger.debug("Loading Sinatra (#{Sinatra::VERSION}) integration")
6
+ Appsignal.internal_logger.debug("Loading Sinatra (#{Sinatra::VERSION}) integration")
7
7
 
8
8
  app_settings = ::Sinatra::Application.settings
9
9
  Appsignal.config = Appsignal::Config.new(
@@ -108,7 +108,7 @@ module Appsignal
108
108
  attr_reader :probes
109
109
 
110
110
  def logger
111
- Appsignal.logger
111
+ Appsignal.internal_logger
112
112
  end
113
113
  end
114
114
 
@@ -132,7 +132,7 @@ module Appsignal
132
132
  sleep initial_wait_time
133
133
  initialize_probes
134
134
  loop do
135
- logger = Appsignal.logger
135
+ logger = Appsignal.internal_logger
136
136
  logger.debug("Gathering minutely metrics with #{probe_instances.count} probes")
137
137
  probe_instances.each do |name, probe|
138
138
  logger.debug("Gathering minutely metrics with '#{name}' probe")
@@ -181,13 +181,13 @@ module Appsignal
181
181
  klass = instance.class
182
182
  end
183
183
  unless dependencies_present?(klass)
184
- Appsignal.logger.debug "Skipping '#{name}' probe, " \
184
+ Appsignal.internal_logger.debug "Skipping '#{name}' probe, " \
185
185
  "#{klass}.dependency_present? returned falsy"
186
186
  return
187
187
  end
188
188
  probe_instances[name] = instance
189
189
  rescue => error
190
- logger = Appsignal.logger
190
+ logger = Appsignal.internal_logger
191
191
  logger.error "Error while initializing minutely probe '#{name}': #{error}"
192
192
  logger.debug error.backtrace.join("\n")
193
193
  end
@@ -22,7 +22,7 @@ module Appsignal
22
22
  end
23
23
 
24
24
  def initialize(appsignal: Appsignal, gvl_tools: ::GVLTools)
25
- Appsignal.logger.debug("Initializing GVL probe")
25
+ Appsignal.internal_logger.debug("Initializing GVL probe")
26
26
  @appsignal = appsignal
27
27
  @gvl_tools = gvl_tools
28
28
  end
@@ -47,7 +47,7 @@ module Appsignal
47
47
  # Auto detect hostname as fallback. May be inaccurate.
48
48
  @hostname =
49
49
  config[:hostname] || Socket.gethostname
50
- Appsignal.logger.debug "Probe helper: Using hostname config " \
50
+ Appsignal.internal_logger.debug "Probe helper: Using hostname config " \
51
51
  "option '#{@hostname.inspect}' as hostname"
52
52
 
53
53
  @hostname
@@ -11,7 +11,7 @@ module Appsignal
11
11
  end
12
12
 
13
13
  def initialize(appsignal: Appsignal, gc_profiler: Appsignal::GarbageCollection.profiler)
14
- Appsignal.logger.debug("Initializing VM probe")
14
+ Appsignal.internal_logger.debug("Initializing VM probe")
15
15
  @appsignal = appsignal
16
16
  @gc_profiler = gc_profiler
17
17
  end
@@ -59,7 +59,7 @@ module Appsignal
59
59
  @adapter = is_sidekiq7 ? Sidekiq7Adapter : Sidekiq6Adapter
60
60
 
61
61
  config_string = " with config: #{config}" unless config.empty?
62
- Appsignal.logger.debug("Initializing Sidekiq probe#{config_string}")
62
+ Appsignal.internal_logger.debug("Initializing Sidekiq probe#{config_string}")
63
63
  require "sidekiq/api"
64
64
  end
65
65
 
@@ -123,14 +123,14 @@ module Appsignal
123
123
 
124
124
  if config.key?(:hostname)
125
125
  @hostname = config[:hostname]
126
- Appsignal.logger.debug "Sidekiq probe: Using hostname config " \
127
- "option #{@hostname.inspect} as hostname"
126
+ Appsignal.internal_logger.debug "Sidekiq probe: Using hostname " \
127
+ "config option #{@hostname.inspect} as hostname"
128
128
  return @hostname
129
129
  end
130
130
 
131
131
  host = adapter.hostname
132
- Appsignal.logger.debug "Sidekiq probe: Using Redis server hostname " \
133
- "#{host.inspect} as hostname"
132
+ Appsignal.internal_logger.debug "Sidekiq probe: Using Redis server " \
133
+ "hostname #{host.inspect} as hostname"
134
134
  @hostname = host
135
135
  end
136
136
  end
@@ -7,7 +7,7 @@ module Appsignal
7
7
  module Rack
8
8
  class GenericInstrumentation
9
9
  def initialize(app, options = {})
10
- Appsignal.logger.debug "Initializing Appsignal::Rack::GenericInstrumentation"
10
+ Appsignal.internal_logger.debug "Initializing Appsignal::Rack::GenericInstrumentation"
11
11
  @app = app
12
12
  @options = options
13
13
  end
@@ -7,7 +7,7 @@ module Appsignal
7
7
  module Rack
8
8
  class RailsInstrumentation
9
9
  def initialize(app, options = {})
10
- Appsignal.logger.debug "Initializing Appsignal::Rack::RailsInstrumentation"
10
+ Appsignal.internal_logger.debug "Initializing Appsignal::Rack::RailsInstrumentation"
11
11
  @app = app
12
12
  @options = options
13
13
  end
@@ -43,7 +43,7 @@ module Appsignal
43
43
  begin
44
44
  transaction.set_metadata("method", request.request_method)
45
45
  rescue => error
46
- Appsignal.logger.error("Unable to report HTTP request method: '#{error}'")
46
+ Appsignal.internal_logger.error("Unable to report HTTP request method: '#{error}'")
47
47
  end
48
48
  Appsignal::Transaction.complete_current!
49
49
  end
@@ -15,7 +15,7 @@ module Appsignal
15
15
  def initialize(app, options = {})
16
16
  @app = app
17
17
  @options = options
18
- Appsignal.logger.warn "Please remove Appsignal::Rack::SinatraInstrumentation " \
18
+ Appsignal.internal_logger.warn "Please remove Appsignal::Rack::SinatraInstrumentation " \
19
19
  "from your Sinatra::Base class. This is no longer needed."
20
20
  end
21
21
 
@@ -32,7 +32,7 @@ module Appsignal
32
32
  attr_reader :raise_errors_on
33
33
 
34
34
  def initialize(app, options = {})
35
- Appsignal.logger.debug "Initializing Appsignal::Rack::SinatraBaseInstrumentation"
35
+ Appsignal.internal_logger.debug "Initializing Appsignal::Rack::SinatraBaseInstrumentation"
36
36
  @app = app
37
37
  @options = options
38
38
  @raise_errors_on = raise_errors?(@app)
@@ -7,7 +7,7 @@ module Appsignal
7
7
  # @api private
8
8
  class StreamingListener
9
9
  def initialize(app, options = {})
10
- Appsignal.logger.debug "Initializing Appsignal::Rack::StreamingListener"
10
+ Appsignal.internal_logger.debug "Initializing Appsignal::Rack::StreamingListener"
11
11
  @app = app
12
12
  @options = options
13
13
  end
@@ -16,8 +16,8 @@ module Appsignal
16
16
 
17
17
  def add_error(error)
18
18
  unless error.is_a?(Exception)
19
- Appsignal.logger.error "Appsignal::Span#add_error: Cannot add error. " \
20
- "The given value is not an exception: #{error.inspect}"
19
+ Appsignal.internal_logger.error "Appsignal::Span#add_error: Cannot " \
20
+ "add error. The given value is not an exception: #{error.inspect}"
21
21
  return
22
22
  end
23
23
  return unless error
@@ -26,7 +26,7 @@ module Appsignal
26
26
  Appsignal::Transaction.new(id, namespace, request, options)
27
27
  else
28
28
  # Otherwise, log the issue about trying to start another transaction
29
- Appsignal.logger.warn_once_then_debug(
29
+ Appsignal.internal_logger.warn_once_then_debug(
30
30
  :transaction_id,
31
31
  "Trying to start new transaction with id " \
32
32
  "'#{id}', but a transaction with id '#{current.transaction_id}' " \
@@ -59,7 +59,7 @@ module Appsignal
59
59
  def complete_current!
60
60
  current.complete
61
61
  rescue => e
62
- Appsignal.logger.error(
62
+ Appsignal.internal_logger.error(
63
63
  "Failed to complete transaction ##{current.transaction_id}. #{e.message}"
64
64
  )
65
65
  ensure
@@ -114,7 +114,7 @@ module Appsignal
114
114
 
115
115
  def complete
116
116
  if discarded?
117
- Appsignal.logger.debug "Skipping transaction '#{transaction_id}' " \
117
+ Appsignal.internal_logger.debug "Skipping transaction '#{transaction_id}' " \
118
118
  "because it was manually discarded."
119
119
  return
120
120
  end
@@ -188,7 +188,7 @@ module Appsignal
188
188
  # Breadcrumb reference
189
189
  def add_breadcrumb(category, action, message = "", metadata = {}, time = Time.now.utc)
190
190
  unless metadata.is_a? Hash
191
- Appsignal.logger.error "add_breadcrumb: Cannot add breadcrumb. " \
191
+ Appsignal.internal_logger.error "add_breadcrumb: Cannot add breadcrumb. " \
192
192
  "The given metadata argument is not a Hash."
193
193
  return
194
194
  end
@@ -287,7 +287,7 @@ module Appsignal
287
287
 
288
288
  @ext.set_queue_start(start)
289
289
  rescue RangeError
290
- Appsignal.logger.warn("Queue start value #{start} is too big")
290
+ Appsignal.internal_logger.warn("Queue start value #{start} is too big")
291
291
  end
292
292
 
293
293
  # Set the queue time based on the HTTP header or `:queue_start` env key
@@ -324,7 +324,7 @@ module Appsignal
324
324
  return unless key && data
325
325
 
326
326
  if !data.is_a?(Array) && !data.is_a?(Hash)
327
- Appsignal.logger.error(
327
+ Appsignal.internal_logger.error(
328
328
  "Invalid sample data for '#{key}'. Value is not an Array or Hash: '#{data.inspect}'"
329
329
  )
330
330
  return
@@ -337,11 +337,11 @@ module Appsignal
337
337
  rescue RuntimeError => e
338
338
  begin
339
339
  inspected_data = data.inspect
340
- Appsignal.logger.error(
340
+ Appsignal.internal_logger.error(
341
341
  "Error generating data (#{e.class}: #{e.message}) for '#{inspected_data}'"
342
342
  )
343
343
  rescue => e
344
- Appsignal.logger.error(
344
+ Appsignal.internal_logger.error(
345
345
  "Error generating data (#{e.class}: #{e.message}). Can't inspect data."
346
346
  )
347
347
  end
@@ -362,7 +362,7 @@ module Appsignal
362
362
 
363
363
  def set_error(error)
364
364
  unless error.is_a?(Exception)
365
- Appsignal.logger.error "Appsignal::Transaction#set_error: Cannot set error. " \
365
+ Appsignal.internal_logger.error "Appsignal::Transaction#set_error: Cannot set error. " \
366
366
  "The given value is not an exception: #{error.inspect}"
367
367
  return
368
368
  end
@@ -385,7 +385,7 @@ module Appsignal
385
385
  break unless error
386
386
 
387
387
  if causes.length >= ERROR_CAUSES_LIMIT
388
- Appsignal.logger.debug "Appsignal::Transaction#set_error: Error has more " \
388
+ Appsignal.internal_logger.debug "Appsignal::Transaction#set_error: Error has more " \
389
389
  "than #{ERROR_CAUSES_LIMIT} error causes. Only the first #{ERROR_CAUSES_LIMIT} " \
390
390
  "will be reported."
391
391
  root_cause_missing = true
@@ -529,7 +529,7 @@ module Appsignal
529
529
  request.send options[:params_method]
530
530
  rescue => e
531
531
  # Getting params from the request has been know to fail.
532
- Appsignal.logger.debug "Exception while getting params: #{e}"
532
+ Appsignal.internal_logger.debug "Exception while getting params: #{e}"
533
533
  nil
534
534
  end
535
535
  end
@@ -3,12 +3,12 @@
3
3
  module Appsignal
4
4
  module Utils
5
5
  module DeprecationMessage
6
- def self.message(message, logger = Appsignal.logger)
6
+ def self.message(message, logger = Appsignal.internal_logger)
7
7
  Kernel.warn "appsignal WARNING: #{message}"
8
8
  logger.warn message
9
9
  end
10
10
 
11
- def deprecation_message(message, logger = Appsignal.logger)
11
+ def deprecation_message(message, logger = Appsignal.internal_logger)
12
12
  Appsignal::Utils::DeprecationMessage.message(message, logger)
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.5.4"
4
+ VERSION = "3.5.5"
5
5
  end
data/lib/appsignal.rb CHANGED
@@ -46,7 +46,11 @@ module Appsignal
46
46
  # @see extension_loaded?
47
47
  attr_accessor :extension_loaded
48
48
  # @!attribute [rw] logger
49
- # Accessor for the AppSignal logger.
49
+ # Accessor for the internal AppSignal logger.
50
+ #
51
+ # Not to be confused with our logging feature.
52
+ # This is part of our private internal API. Do not call this method
53
+ # directly.
50
54
  #
51
55
  # If no logger has been set, it will return a "in memory logger", using
52
56
  # `in_memory_log`. Once AppSignal is started (using {.start}) the
@@ -57,7 +61,7 @@ module Appsignal
57
61
  # @api private
58
62
  # @return [Logger]
59
63
  # @see start_logger
60
- attr_writer :logger
64
+ attr_writer :internal_logger
61
65
 
62
66
  # @api private
63
67
  def testing?
@@ -91,11 +95,11 @@ module Appsignal
91
95
  # @since 0.7.0
92
96
  def start
93
97
  unless extension_loaded?
94
- logger.info("Not starting appsignal, extension is not loaded")
98
+ internal_logger.info("Not starting appsignal, extension is not loaded")
95
99
  return
96
100
  end
97
101
 
98
- logger.debug("Starting appsignal")
102
+ internal_logger.debug("Starting appsignal")
99
103
 
100
104
  @config ||= Config.new(
101
105
  Dir.pwd,
@@ -103,9 +107,9 @@ module Appsignal
103
107
  )
104
108
 
105
109
  if config.valid?
106
- logger.level = config.log_level
110
+ internal_logger.level = config.log_level
107
111
  if config.active?
108
- logger.info "Starting AppSignal #{Appsignal::VERSION} " \
112
+ internal_logger.info "Starting AppSignal #{Appsignal::VERSION} " \
109
113
  "(#{$PROGRAM_NAME}, Ruby #{RUBY_VERSION}, #{RUBY_PLATFORM})"
110
114
  config.write_to_environment
111
115
  Appsignal::Extension.start
@@ -120,10 +124,10 @@ module Appsignal
120
124
 
121
125
  collect_environment_metadata
122
126
  else
123
- logger.info("Not starting, not active for #{config.env}")
127
+ internal_logger.info("Not starting, not active for #{config.env}")
124
128
  end
125
129
  else
126
- logger.error("Not starting, no valid config for this environment")
130
+ internal_logger.error("Not starting, no valid config for this environment")
127
131
  end
128
132
  end
129
133
 
@@ -143,9 +147,9 @@ module Appsignal
143
147
  # @since 1.0.0
144
148
  def stop(called_by = nil)
145
149
  if called_by
146
- logger.debug("Stopping appsignal (#{called_by})")
150
+ internal_logger.debug("Stopping appsignal (#{called_by})")
147
151
  else
148
- logger.debug("Stopping appsignal")
152
+ internal_logger.debug("Stopping appsignal")
149
153
  end
150
154
  Appsignal::Extension.stop
151
155
  end
@@ -154,7 +158,7 @@ module Appsignal
154
158
  return unless active?
155
159
 
156
160
  Appsignal.start_logger
157
- logger.debug("Forked process, resubscribing and restarting extension")
161
+ internal_logger.debug("Forked process, resubscribing and restarting extension")
158
162
  Appsignal::Extension.start
159
163
  end
160
164
 
@@ -162,7 +166,8 @@ module Appsignal
162
166
  Appsignal::Extension.get_server_state(key)
163
167
  end
164
168
 
165
- # In memory logger used before any logger is started with {.start_logger}.
169
+ # In memory internal logger used before any internal logger is started with
170
+ # {.start_logger}.
166
171
  #
167
172
  # The contents of this logger are flushed to the logger in {.start_logger}.
168
173
  #
@@ -176,11 +181,12 @@ module Appsignal
176
181
  end
177
182
  end
178
183
 
179
- def logger
180
- @logger ||= Appsignal::Utils::IntegrationLogger.new(in_memory_log).tap do |l|
181
- l.level = ::Logger::INFO
182
- l.formatter = log_formatter("appsignal")
183
- end
184
+ def internal_logger
185
+ @internal_logger ||=
186
+ Appsignal::Utils::IntegrationLogger.new(in_memory_log).tap do |l|
187
+ l.level = ::Logger::INFO
188
+ l.formatter = log_formatter("appsignal")
189
+ end
184
190
  end
185
191
 
186
192
  # @api private
@@ -192,7 +198,7 @@ module Appsignal
192
198
  end
193
199
  end
194
200
 
195
- # Start the AppSignal logger.
201
+ # Start the AppSignal internal logger.
196
202
  #
197
203
  # Sets the log level and sets the logger. Uses a file-based logger or the
198
204
  # STDOUT-based logger. See the `:log` configuration option.
@@ -201,18 +207,18 @@ module Appsignal
201
207
  # @since 0.7.0
202
208
  def start_logger
203
209
  if config && config[:log] == "file" && config.log_file_path
204
- start_file_logger(config.log_file_path)
210
+ start_internal_file_logger(config.log_file_path)
205
211
  else
206
- start_stdout_logger
212
+ start_internal_stdout_logger
207
213
  end
208
214
 
209
- logger.level =
215
+ internal_logger.level =
210
216
  if config
211
217
  config.log_level
212
218
  else
213
219
  Appsignal::Config::DEFAULT_LOG_LEVEL
214
220
  end
215
- logger << @in_memory_log.string if @in_memory_log
221
+ internal_logger << @in_memory_log.string if @in_memory_log
216
222
  end
217
223
 
218
224
  # Returns if the C-extension was loaded properly.
@@ -255,18 +261,18 @@ module Appsignal
255
261
 
256
262
  private
257
263
 
258
- def start_stdout_logger
259
- @logger = Appsignal::Utils::IntegrationLogger.new($stdout)
260
- logger.formatter = log_formatter("appsignal")
264
+ def start_internal_stdout_logger
265
+ @internal_logger = Appsignal::Utils::IntegrationLogger.new($stdout)
266
+ internal_logger.formatter = log_formatter("appsignal")
261
267
  end
262
268
 
263
- def start_file_logger(path)
264
- @logger = Appsignal::Utils::IntegrationLogger.new(path)
265
- logger.formatter = log_formatter
269
+ def start_internal_file_logger(path)
270
+ @internal_logger = Appsignal::Utils::IntegrationLogger.new(path)
271
+ internal_logger.formatter = log_formatter
266
272
  rescue SystemCallError => error
267
- start_stdout_logger
268
- logger.warn "Unable to start logger with log path '#{path}'."
269
- logger.warn error
273
+ start_internal_stdout_logger
274
+ internal_logger.warn "Unable to start internal logger with log path '#{path}'."
275
+ internal_logger.warn error
270
276
  end
271
277
 
272
278
  def collect_environment_metadata
@@ -265,7 +265,7 @@ describe Appsignal::Config do
265
265
 
266
266
  context "with an overriden config file" do
267
267
  let(:config) do
268
- project_fixture_config("production", {}, Appsignal.logger,
268
+ project_fixture_config("production", {}, Appsignal.internal_logger,
269
269
  File.join(project_fixture_path, "config", "appsignal.yml"))
270
270
  end
271
271
 
@@ -276,7 +276,7 @@ describe Appsignal::Config do
276
276
 
277
277
  context "with an invalid overriden config file" do
278
278
  let(:config) do
279
- project_fixture_config("production", {}, Appsignal.logger,
279
+ project_fixture_config("production", {}, Appsignal.internal_logger,
280
280
  File.join(project_fixture_path, "config", "missing.yml"))
281
281
  end
282
282