scout_apm_logging 0.0.4 → 0.0.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/scout_apm/logging/loggers/logger.rb +11 -1
- data/lib/scout_apm/logging/loggers/swaps/rails.rb +1 -0
- data/lib/scout_apm/logging/loggers/swaps/scout.rb +1 -0
- data/lib/scout_apm/logging/loggers/swaps/sidekiq.rb +1 -0
- data/lib/scout_apm/logging/monitor/collector/configuration.rb +2 -0
- data/lib/scout_apm/logging/version.rb +1 -1
- data/spec/integration/rails/lifecycle_spec.rb +1 -0
- data/spec/rails/app.rb +3 -0
- data/spec/unit/loggers/capture_spec.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55380380a6a30ccfe38b8a7b117e02e2aa8c3ffc09a679f194c0b93ed1f4062
|
4
|
+
data.tar.gz: 0131aa6a8d6ed072553996fe58b5a4e3d1f1170e656dda3b8283bbad301f56e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddada293aa30a8c806e6ca1e7d318b5a2f412f990d2bd5e2eeb81e5ddd10d661a7362571c105d776f7c5adbeecd4d6adf788ba505c6d6b811f8824f30485550e
|
7
|
+
data.tar.gz: 825aba7b09c6075bcb0230b18b582eb37daa08d0c2eff45c781c73efa8a058dbae4498e1702e14438320a3bf618aae52d738b81aabfa7e87b825a1efed827da8
|
data/CHANGELOG.md
CHANGED
@@ -25,7 +25,7 @@ module ScoutApm
|
|
25
25
|
|
26
26
|
FileLogger.new(determine_file_path, LOG_AGE, log_size).tap do |logger|
|
27
27
|
# Ruby's Logger handles a lot of the coercion itself.
|
28
|
-
logger.level =
|
28
|
+
logger.level = determined_log_level
|
29
29
|
# Add our custom formatter to the logger.
|
30
30
|
logger.formatter = Formatter.new
|
31
31
|
end
|
@@ -55,6 +55,16 @@ module ScoutApm
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
+
# This makes the assumption that the logs we capture should be
|
59
|
+
# at least that of the original logger level, and not lower, but can be
|
60
|
+
# configured to be a higher cutoff.
|
61
|
+
def determined_log_level
|
62
|
+
capture_level = context.config.value('logs_capture_level')
|
63
|
+
capture_value = ::Logger::Severity.const_get(capture_level.upcase)
|
64
|
+
|
65
|
+
[capture_value, log_instance.level].max
|
66
|
+
end
|
67
|
+
|
58
68
|
def find_log_destination(logdev)
|
59
69
|
dev = try(logdev, :filename) || try(logdev, :dev)
|
60
70
|
if dev.is_a?(String)
|
@@ -95,6 +95,8 @@ module ScoutApm
|
|
95
95
|
- 'set(attributes["raw_bytes"], body)'
|
96
96
|
# Replace the body with the log message.
|
97
97
|
- 'set(body, attributes["msg"])'
|
98
|
+
# Remove the msg attribute.
|
99
|
+
- 'delete_key(attributes, "msg")'
|
98
100
|
# Move service.name attribute to resource attribute.
|
99
101
|
- 'set(resource.attributes["service.name"], attributes["service.name"])'
|
100
102
|
batch:
|
@@ -47,6 +47,7 @@ describe ScoutApm::Logging do
|
|
47
47
|
expect(messages.count('[TEST] Some log')).to eq(1)
|
48
48
|
expect(messages.count('[YIELD] Yield Test')).to eq(1)
|
49
49
|
expect(messages.count('Another Log')).to eq(1)
|
50
|
+
expect(messages.count('Should not be captured')).to eq(0)
|
50
51
|
|
51
52
|
log_locations = lines.map { |item| item['log_location'] }.compact
|
52
53
|
|
data/spec/rails/app.rb
CHANGED
@@ -12,6 +12,7 @@ Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
|
|
12
12
|
|
13
13
|
class App < ::Rails::Application
|
14
14
|
config.eager_load = false
|
15
|
+
config.log_level = :info
|
15
16
|
|
16
17
|
routes.append do
|
17
18
|
root to: 'root#index'
|
@@ -24,6 +25,8 @@ class RootController < ActionController::Base
|
|
24
25
|
Rails.logger.tagged('TEST').info('Some log')
|
25
26
|
Rails.logger.tagged('YIELD') { logger.info('Yield Test') }
|
26
27
|
Rails.logger.info('Another Log')
|
28
|
+
Rails.logger.debug('Should not be captured')
|
29
|
+
|
27
30
|
render plain: Rails.version
|
28
31
|
end
|
29
32
|
end
|
@@ -19,6 +19,7 @@ describe ScoutApm::Logging::Loggers::Capture do
|
|
19
19
|
ENV['SCOUT_MONITOR_INTERVAL'] = '10'
|
20
20
|
ENV['SCOUT_MONITOR_INTERVAL_DELAY'] = '10'
|
21
21
|
ENV['SCOUT_LOGS_MONITOR'] = 'true'
|
22
|
+
ENV['SCOUT_LOGS_CAPTURE_LEVEL'] = 'debug'
|
22
23
|
|
23
24
|
output_from_log = capture_stdout do
|
24
25
|
context = ScoutApm::Logging::Context.new
|
@@ -26,7 +27,10 @@ describe ScoutApm::Logging::Loggers::Capture do
|
|
26
27
|
conf = ScoutApm::Logging::Config.with_file(context, conf_file)
|
27
28
|
context.config = conf
|
28
29
|
|
29
|
-
|
30
|
+
test_logger = ScoutTestLogger.new($stdout)
|
31
|
+
test_logger.level = 'INFO'
|
32
|
+
|
33
|
+
TestLoggerWrapper.logger = test_logger
|
30
34
|
|
31
35
|
capture = ScoutApm::Logging::Loggers::Capture.new(context)
|
32
36
|
capture.setup!
|
@@ -34,16 +38,22 @@ describe ScoutApm::Logging::Loggers::Capture do
|
|
34
38
|
expect(TestLoggerWrapper.logger.class).to eq(ScoutApm::Logging::Loggers::Proxy)
|
35
39
|
|
36
40
|
TestLoggerWrapper.logger.info('TEST')
|
41
|
+
TestLoggerWrapper.logger.debug('SHOULD NOT CAPTURE')
|
37
42
|
|
38
43
|
log_path = File.join(context.config.value('logs_proxy_log_dir'), 'test.log')
|
39
44
|
content = File.read(log_path)
|
40
45
|
expect(content).to include('TEST')
|
41
46
|
|
47
|
+
# Shouldn't capture. While the log_capture_level was set to debug,
|
48
|
+
# the original logger instance had a higher log level of info.
|
49
|
+
expect(content).not_to include('SHOULD NOT CAPTURE')
|
50
|
+
|
42
51
|
state_file = File.read(context.config.value('monitor_state_file'))
|
43
52
|
state_data = JSON.parse(state_file)
|
44
53
|
expect(state_data['logs_monitored']).to eq([log_path])
|
45
54
|
end
|
46
55
|
|
47
56
|
expect(output_from_log).to include('TEST')
|
57
|
+
expect(output_from_log).not_to include('SHOULD NOT CAPTURE')
|
48
58
|
end
|
49
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_apm_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scout APM
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scout_apm
|