appsignal 3.4.13 → 3.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +180 -14
- data/CHANGELOG.md +164 -0
- data/README.md +2 -0
- data/Rakefile +3 -1
- data/build_matrix.yml +7 -13
- data/ext/Rakefile +8 -1
- data/ext/agent.rb +27 -27
- data/ext/appsignal_extension.c +0 -24
- data/ext/base.rb +4 -1
- data/gemfiles/redis-4.gemfile +5 -0
- data/gemfiles/redis-5.gemfile +6 -0
- data/lib/appsignal/cli/diagnose/paths.rb +33 -10
- data/lib/appsignal/cli/diagnose.rb +6 -1
- data/lib/appsignal/config.rb +19 -5
- data/lib/appsignal/demo.rb +1 -1
- data/lib/appsignal/environment.rb +24 -13
- data/lib/appsignal/event_formatter.rb +1 -1
- data/lib/appsignal/extension/jruby.rb +4 -17
- data/lib/appsignal/extension.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +10 -10
- data/lib/appsignal/helpers/metrics.rb +15 -13
- data/lib/appsignal/hooks/active_job.rb +9 -1
- data/lib/appsignal/hooks/redis.rb +1 -0
- data/lib/appsignal/hooks/redis_client.rb +27 -0
- data/lib/appsignal/hooks.rb +3 -2
- data/lib/appsignal/integrations/hanami.rb +1 -1
- data/lib/appsignal/integrations/padrino.rb +1 -1
- data/lib/appsignal/integrations/railtie.rb +1 -1
- data/lib/appsignal/integrations/redis_client.rb +20 -0
- data/lib/appsignal/integrations/sidekiq.rb +2 -2
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/logger.rb +2 -0
- data/lib/appsignal/minutely.rb +4 -4
- data/lib/appsignal/probes/gvl.rb +1 -1
- data/lib/appsignal/probes/helpers.rb +1 -1
- data/lib/appsignal/probes/mri.rb +1 -1
- data/lib/appsignal/probes/sidekiq.rb +10 -8
- data/lib/appsignal/rack/body_wrapper.rb +161 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +18 -5
- data/lib/appsignal/rack/rails_instrumentation.rb +17 -5
- data/lib/appsignal/rack/sinatra_instrumentation.rb +17 -5
- data/lib/appsignal/rack/streaming_listener.rb +27 -36
- data/lib/appsignal/span.rb +2 -2
- data/lib/appsignal/transaction.rb +46 -10
- data/lib/appsignal/utils/deprecation_message.rb +2 -2
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +38 -31
- data/resources/cacert.pem +321 -159
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +11 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +38 -12
- data/spec/lib/appsignal/config_spec.rb +3 -2
- data/spec/lib/appsignal/hooks/activejob_spec.rb +26 -1
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +222 -0
- data/spec/lib/appsignal/hooks/redis_spec.rb +98 -76
- data/spec/lib/appsignal/hooks_spec.rb +4 -4
- data/spec/lib/appsignal/integrations/railtie_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
- data/spec/lib/appsignal/minutely_spec.rb +2 -2
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +29 -6
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +220 -0
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +3 -2
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +5 -3
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +3 -1
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +9 -53
- data/spec/lib/appsignal/transaction_spec.rb +95 -2
- data/spec/lib/appsignal_spec.rb +62 -60
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +3 -3
- data/spec/support/helpers/config_helpers.rb +6 -2
- data/spec/support/helpers/dependency_helper.rb +9 -1
- data/spec/support/helpers/log_helpers.rb +2 -2
- metadata +9 -2
@@ -15,7 +15,7 @@ module Appsignal
|
|
15
15
|
def initialize(app, options = {})
|
16
16
|
@app = app
|
17
17
|
@options = options
|
18
|
-
Appsignal.
|
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.
|
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)
|
@@ -42,7 +42,9 @@ module Appsignal
|
|
42
42
|
if Appsignal.active?
|
43
43
|
call_with_appsignal_monitoring(env)
|
44
44
|
else
|
45
|
-
|
45
|
+
nil_transaction = Appsignal::Transaction::NilTransaction.new
|
46
|
+
status, headers, obody = @app.call(env)
|
47
|
+
[status, headers, Appsignal::Rack::BodyWrapper.wrap(obody, nil_transaction)]
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -56,12 +58,19 @@ module Appsignal
|
|
56
58
|
request,
|
57
59
|
options
|
58
60
|
)
|
61
|
+
# We need to complete the transaction if there is an exception exception inside the `call`
|
62
|
+
# of the app. If there isn't one and the app returns us a Rack response triplet, we let
|
63
|
+
# the BodyWrapper complete the transaction when #close gets called on it
|
64
|
+
# (guaranteed by the webserver)
|
65
|
+
complete_transaction_without_body = false
|
59
66
|
begin
|
60
67
|
Appsignal.instrument("process_action.sinatra") do
|
61
|
-
@app.call(env)
|
68
|
+
status, headers, obody = @app.call(env)
|
69
|
+
[status, headers, Appsignal::Rack::BodyWrapper.wrap(obody, transaction)]
|
62
70
|
end
|
63
71
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
64
72
|
transaction.set_error(error)
|
73
|
+
complete_transaction_without_body = true
|
65
74
|
raise error
|
66
75
|
ensure
|
67
76
|
# If raise_error is off versions of Sinatra don't raise errors, but store
|
@@ -73,7 +82,10 @@ module Appsignal
|
|
73
82
|
transaction.set_metadata("path", request.path)
|
74
83
|
transaction.set_metadata("method", request.request_method)
|
75
84
|
transaction.set_http_or_background_queue_start
|
76
|
-
|
85
|
+
|
86
|
+
# Transaction gets completed when the body gets read out, except in cases when
|
87
|
+
# the app failed before returning us the Rack response triplet.
|
88
|
+
Appsignal::Transaction.complete_current! if complete_transaction_without_body
|
77
89
|
end
|
78
90
|
end
|
79
91
|
|
@@ -7,7 +7,7 @@ module Appsignal
|
|
7
7
|
# @api private
|
8
8
|
class StreamingListener
|
9
9
|
def initialize(app, options = {})
|
10
|
-
Appsignal.
|
10
|
+
Appsignal.internal_logger.debug "Initializing Appsignal::Rack::StreamingListener"
|
11
11
|
@app = app
|
12
12
|
@options = options
|
13
13
|
end
|
@@ -16,7 +16,9 @@ module Appsignal
|
|
16
16
|
if Appsignal.active?
|
17
17
|
call_with_appsignal_monitoring(env)
|
18
18
|
else
|
19
|
-
|
19
|
+
nil_transaction = Appsignal::Transaction::NilTransaction.new
|
20
|
+
status, headers, obody = @app.call(env)
|
21
|
+
[status, headers, Appsignal::Rack::BodyWrapper.wrap(obody, nil_transaction)]
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -28,46 +30,35 @@ module Appsignal
|
|
28
30
|
request
|
29
31
|
)
|
30
32
|
|
33
|
+
# We need to complete the transaction if there is an exception exception inside the `call`
|
34
|
+
# of the app. If there isn't one and the app returns us a Rack response triplet, we let
|
35
|
+
# the BodyWrapper complete the transaction when #close gets called on it
|
36
|
+
# (guaranteed by the webserver)
|
37
|
+
complete_transaction_without_body = false
|
38
|
+
|
31
39
|
# Instrument a `process_action`, to set params/action name
|
32
|
-
|
40
|
+
begin
|
33
41
|
Appsignal.instrument("process_action.rack") do
|
34
|
-
@app.call(env)
|
35
|
-
|
36
|
-
transaction.set_error(e)
|
37
|
-
raise e
|
38
|
-
ensure
|
39
|
-
transaction.set_action_if_nil(env["appsignal.action"])
|
40
|
-
transaction.set_metadata("path", request.path)
|
41
|
-
transaction.set_metadata("method", request.request_method)
|
42
|
-
transaction.set_http_or_background_queue_start
|
42
|
+
status, headers, obody = @app.call(env)
|
43
|
+
[status, headers, Appsignal::Rack::BodyWrapper.wrap(obody, transaction)]
|
43
44
|
end
|
45
|
+
rescue Exception => error # rubocop:disable Lint/RescueException
|
46
|
+
transaction.set_error(error)
|
47
|
+
complete_transaction_without_body = true
|
48
|
+
raise error
|
49
|
+
ensure
|
50
|
+
transaction.set_action_if_nil(env["appsignal.action"])
|
51
|
+
transaction.set_metadata("path", request.path)
|
52
|
+
transaction.set_metadata("method", request.request_method)
|
53
|
+
transaction.set_http_or_background_queue_start
|
44
54
|
|
45
|
-
|
46
|
-
|
55
|
+
# Transaction gets completed when the body gets read out, except in cases when
|
56
|
+
# the app failed before returning us the Rack response triplet.
|
57
|
+
Appsignal::Transaction.complete_current! if complete_transaction_without_body
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
50
62
|
|
51
|
-
|
52
|
-
def initialize(stream, transaction)
|
53
|
-
@stream = stream
|
54
|
-
@transaction = transaction
|
55
|
-
end
|
56
|
-
|
57
|
-
def each(&block)
|
58
|
-
@stream.each(&block)
|
59
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
60
|
-
@transaction.set_error(e)
|
61
|
-
raise e
|
62
|
-
end
|
63
|
-
|
64
|
-
def close
|
65
|
-
@stream.close if @stream.respond_to?(:close)
|
66
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
67
|
-
@transaction.set_error(e)
|
68
|
-
raise e
|
69
|
-
ensure
|
70
|
-
Appsignal::Transaction.complete_current!
|
71
|
-
end
|
72
|
-
end
|
63
|
+
StreamWrapper = Rack::EnumerableBodyWrapper
|
73
64
|
end
|
data/lib/appsignal/span.rb
CHANGED
@@ -16,8 +16,8 @@ module Appsignal
|
|
16
16
|
|
17
17
|
def add_error(error)
|
18
18
|
unless error.is_a?(Exception)
|
19
|
-
Appsignal.
|
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
|
@@ -12,6 +12,7 @@ module Appsignal
|
|
12
12
|
ALLOWED_TAG_KEY_TYPES = [Symbol, String].freeze
|
13
13
|
ALLOWED_TAG_VALUE_TYPES = [Symbol, String, Integer].freeze
|
14
14
|
BREADCRUMB_LIMIT = 20
|
15
|
+
ERROR_CAUSES_LIMIT = 10
|
15
16
|
|
16
17
|
class << self
|
17
18
|
def create(id, namespace, request, options = {})
|
@@ -25,7 +26,7 @@ module Appsignal
|
|
25
26
|
Appsignal::Transaction.new(id, namespace, request, options)
|
26
27
|
else
|
27
28
|
# Otherwise, log the issue about trying to start another transaction
|
28
|
-
Appsignal.
|
29
|
+
Appsignal.internal_logger.warn_once_then_debug(
|
29
30
|
:transaction_id,
|
30
31
|
"Trying to start new transaction with id " \
|
31
32
|
"'#{id}', but a transaction with id '#{current.transaction_id}' " \
|
@@ -58,7 +59,7 @@ module Appsignal
|
|
58
59
|
def complete_current!
|
59
60
|
current.complete
|
60
61
|
rescue => e
|
61
|
-
Appsignal.
|
62
|
+
Appsignal.internal_logger.error(
|
62
63
|
"Failed to complete transaction ##{current.transaction_id}. #{e.message}"
|
63
64
|
)
|
64
65
|
ensure
|
@@ -113,7 +114,7 @@ module Appsignal
|
|
113
114
|
|
114
115
|
def complete
|
115
116
|
if discarded?
|
116
|
-
Appsignal.
|
117
|
+
Appsignal.internal_logger.debug "Skipping transaction '#{transaction_id}' " \
|
117
118
|
"because it was manually discarded."
|
118
119
|
return
|
119
120
|
end
|
@@ -187,7 +188,7 @@ module Appsignal
|
|
187
188
|
# Breadcrumb reference
|
188
189
|
def add_breadcrumb(category, action, message = "", metadata = {}, time = Time.now.utc)
|
189
190
|
unless metadata.is_a? Hash
|
190
|
-
Appsignal.
|
191
|
+
Appsignal.internal_logger.error "add_breadcrumb: Cannot add breadcrumb. " \
|
191
192
|
"The given metadata argument is not a Hash."
|
192
193
|
return
|
193
194
|
end
|
@@ -286,7 +287,7 @@ module Appsignal
|
|
286
287
|
|
287
288
|
@ext.set_queue_start(start)
|
288
289
|
rescue RangeError
|
289
|
-
Appsignal.
|
290
|
+
Appsignal.internal_logger.warn("Queue start value #{start} is too big")
|
290
291
|
end
|
291
292
|
|
292
293
|
# Set the queue time based on the HTTP header or `:queue_start` env key
|
@@ -323,7 +324,7 @@ module Appsignal
|
|
323
324
|
return unless key && data
|
324
325
|
|
325
326
|
if !data.is_a?(Array) && !data.is_a?(Hash)
|
326
|
-
Appsignal.
|
327
|
+
Appsignal.internal_logger.error(
|
327
328
|
"Invalid sample data for '#{key}'. Value is not an Array or Hash: '#{data.inspect}'"
|
328
329
|
)
|
329
330
|
return
|
@@ -336,11 +337,11 @@ module Appsignal
|
|
336
337
|
rescue RuntimeError => e
|
337
338
|
begin
|
338
339
|
inspected_data = data.inspect
|
339
|
-
Appsignal.
|
340
|
+
Appsignal.internal_logger.error(
|
340
341
|
"Error generating data (#{e.class}: #{e.message}) for '#{inspected_data}'"
|
341
342
|
)
|
342
343
|
rescue => e
|
343
|
-
Appsignal.
|
344
|
+
Appsignal.internal_logger.error(
|
344
345
|
"Error generating data (#{e.class}: #{e.message}). Can't inspect data."
|
345
346
|
)
|
346
347
|
end
|
@@ -361,7 +362,7 @@ module Appsignal
|
|
361
362
|
|
362
363
|
def set_error(error)
|
363
364
|
unless error.is_a?(Exception)
|
364
|
-
Appsignal.
|
365
|
+
Appsignal.internal_logger.error "Appsignal::Transaction#set_error: Cannot set error. " \
|
365
366
|
"The given value is not an exception: #{error.inspect}"
|
366
367
|
return
|
367
368
|
end
|
@@ -374,6 +375,41 @@ module Appsignal
|
|
374
375
|
cleaned_error_message(error),
|
375
376
|
backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new
|
376
377
|
)
|
378
|
+
|
379
|
+
root_cause_missing = false
|
380
|
+
|
381
|
+
causes = []
|
382
|
+
while error
|
383
|
+
error = error.cause
|
384
|
+
|
385
|
+
break unless error
|
386
|
+
|
387
|
+
if causes.length >= ERROR_CAUSES_LIMIT
|
388
|
+
Appsignal.internal_logger.debug "Appsignal::Transaction#set_error: Error has more " \
|
389
|
+
"than #{ERROR_CAUSES_LIMIT} error causes. Only the first #{ERROR_CAUSES_LIMIT} " \
|
390
|
+
"will be reported."
|
391
|
+
root_cause_missing = true
|
392
|
+
break
|
393
|
+
end
|
394
|
+
|
395
|
+
causes << error
|
396
|
+
end
|
397
|
+
|
398
|
+
return if causes.empty?
|
399
|
+
|
400
|
+
causes_sample_data = causes.map do |e|
|
401
|
+
{
|
402
|
+
:name => e.class.name,
|
403
|
+
:message => cleaned_error_message(e)
|
404
|
+
}
|
405
|
+
end
|
406
|
+
|
407
|
+
causes_sample_data.last[:is_root_cause] = false if root_cause_missing
|
408
|
+
|
409
|
+
set_sample_data(
|
410
|
+
"error_causes",
|
411
|
+
causes_sample_data
|
412
|
+
)
|
377
413
|
end
|
378
414
|
alias_method :add_exception, :set_error
|
379
415
|
|
@@ -493,7 +529,7 @@ module Appsignal
|
|
493
529
|
request.send options[:params_method]
|
494
530
|
rescue => e
|
495
531
|
# Getting params from the request has been know to fail.
|
496
|
-
Appsignal.
|
532
|
+
Appsignal.internal_logger.debug "Exception while getting params: #{e}"
|
497
533
|
nil
|
498
534
|
end
|
499
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.
|
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.
|
11
|
+
def deprecation_message(message, logger = Appsignal.internal_logger)
|
12
12
|
Appsignal::Utils::DeprecationMessage.message(message, logger)
|
13
13
|
end
|
14
14
|
end
|
data/lib/appsignal/version.rb
CHANGED
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 :
|
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
|
-
|
98
|
+
internal_logger.info("Not starting appsignal, extension is not loaded")
|
95
99
|
return
|
96
100
|
end
|
97
101
|
|
98
|
-
|
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
|
-
|
110
|
+
internal_logger.level = config.log_level
|
107
111
|
if config.active?
|
108
|
-
|
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
|
-
|
127
|
+
internal_logger.info("Not starting, not active for #{config.env}")
|
124
128
|
end
|
125
129
|
else
|
126
|
-
|
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
|
-
|
150
|
+
internal_logger.debug("Stopping appsignal (#{called_by})")
|
147
151
|
else
|
148
|
-
|
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
|
-
|
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
|
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
|
180
|
-
@
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
-
|
210
|
+
start_internal_file_logger(config.log_file_path)
|
205
211
|
else
|
206
|
-
|
212
|
+
start_internal_stdout_logger
|
207
213
|
end
|
208
214
|
|
209
|
-
|
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
|
-
|
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
|
259
|
-
@
|
260
|
-
|
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
|
264
|
-
@
|
265
|
-
|
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
|
-
|
268
|
-
|
269
|
-
|
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
|
@@ -299,5 +305,6 @@ require "appsignal/garbage_collection"
|
|
299
305
|
require "appsignal/integrations/railtie" if defined?(::Rails)
|
300
306
|
require "appsignal/transaction"
|
301
307
|
require "appsignal/version"
|
308
|
+
require "appsignal/rack/body_wrapper"
|
302
309
|
require "appsignal/rack/generic_instrumentation"
|
303
310
|
require "appsignal/transmitter"
|