scout_apm_logging 0.0.11 → 0.0.12
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/bin/scout_apm_logging_monitor +1 -0
- data/lib/scout_apm/logging/loggers/logger.rb +15 -0
- data/lib/scout_apm/logging/loggers/patches/tagged_logging.rb +2 -2
- data/lib/scout_apm/logging/loggers/proxy.rb +22 -1
- data/lib/scout_apm/logging/loggers/swaps/rails.rb +2 -2
- data/lib/scout_apm/logging/monitor/_rails.rb +22 -0
- data/lib/scout_apm/logging/version.rb +1 -1
- data/spec/unit/loggers/capture_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea114282e91583732d4a4b3246273d0b18ae3b2e5b784366b5a18691889391b
|
4
|
+
data.tar.gz: dd625a2eb6bede54138bb05ef3671ad1a98995d59f1c5de28d033fd617d156b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d62832832aa309c9bd66c5cabe2d6c4c23472452bd0f3b9874741febd5f0a5f6716dfea8ff5e929075424ea998a89eb0edb947da9959d0bf03da334a9502158
|
7
|
+
data.tar.gz: 94ab281a893c87b2d1b979b4b8fa7c9c2bd0e467983b302c0f0931b04f582dc6dc2c6b9c3c19b83ad14b79ece26a6b4a5f0c7e6cda492b6b840c133ec9d7d5f2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.0.12
|
2
|
+
* Prevent certain attributes from being changed on created FileLogger.
|
3
|
+
* Update proxy class to inherit from BasicObject to relay class comparison methods
|
4
|
+
to held loggers.
|
5
|
+
* Fix ERB evaluation in scout_apm.yml config file to allow for usage of Rails.env.
|
6
|
+
|
1
7
|
## 0.0.11
|
2
8
|
* Fix Scout layer capturing in log attributes for background jobs.
|
3
9
|
|
@@ -6,6 +6,21 @@ module ScoutApm
|
|
6
6
|
# The actual instance of the logger.
|
7
7
|
class FileLogger < ::Logger
|
8
8
|
include ::ActiveSupport::LoggerSilence if const_defined?('::ActiveSupport::LoggerSilence')
|
9
|
+
|
10
|
+
# Other loggers may be extended with additional methods that have not been applied to this file logger.
|
11
|
+
# Most likely, these methods will still utilize the exiting logging methods to write to the IO device,
|
12
|
+
# however, if this is not the case we may miss logs. With that being said, we shouldn't impact the original
|
13
|
+
# applications intended behavior and let the user know we don't support it and no-op.
|
14
|
+
def method_missing(name, *_args)
|
15
|
+
return unless defined?(::Rails)
|
16
|
+
|
17
|
+
::Rails.logger.warn("Method #{name} called on ScoutApm::Logging::Loggers::FileLogger, but it is not defined.")
|
18
|
+
end
|
19
|
+
|
20
|
+
# More impactful for the broadcast logger.
|
21
|
+
def respond_to_missing?(name, *_args)
|
22
|
+
super
|
23
|
+
end
|
9
24
|
end
|
10
25
|
|
11
26
|
# The newly created logger which we can configure, and will log to a filepath.
|
@@ -11,10 +11,10 @@ module ScoutApm
|
|
11
11
|
# Patches TaggedLogging to work with our loggers.
|
12
12
|
module TaggedLogging
|
13
13
|
def tagged(*tags) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
14
|
-
return super(*tags) unless (self == ::Rails.logger &&
|
14
|
+
return super(*tags) unless (self == ::Rails.logger && respond_to?(:is_scout_proxy_logger?)) ||
|
15
15
|
(::Rails.logger.respond_to?(:broadcasts) && ::Rails.logger.broadcasts.include?(self))
|
16
16
|
|
17
|
-
if
|
17
|
+
if respond_to?(:is_scout_proxy_logger?)
|
18
18
|
if block_given?
|
19
19
|
# We skip the first logger to prevent double tagging when calling formatter.tagged
|
20
20
|
loggers = @loggers[1..]
|
@@ -4,7 +4,9 @@ module ScoutApm
|
|
4
4
|
module Logging
|
5
5
|
module Loggers
|
6
6
|
# Holds both the original application logger and the new one. Relays commands to both.
|
7
|
-
class Proxy
|
7
|
+
class Proxy < BasicObject
|
8
|
+
include ::Kernel
|
9
|
+
|
8
10
|
def self.create_with_loggers(*loggers)
|
9
11
|
new.tap do |proxy_logger|
|
10
12
|
loggers.each { |logger| proxy_logger.add_scout_loggers(logger) }
|
@@ -25,6 +27,25 @@ module ScoutApm
|
|
25
27
|
@loggers
|
26
28
|
end
|
27
29
|
|
30
|
+
# We don't want other libraries to change the formatter of the logger we create.
|
31
|
+
def formatter=(formatter)
|
32
|
+
@loggers.first.formatter = formatter
|
33
|
+
end
|
34
|
+
|
35
|
+
# We don't want other libraries to change the level of the logger we create, as this
|
36
|
+
# is dictated by the logs_capture_level configuration.
|
37
|
+
def level=(level)
|
38
|
+
@loggers.first.level = level
|
39
|
+
end
|
40
|
+
|
41
|
+
def class
|
42
|
+
::Logger
|
43
|
+
end
|
44
|
+
|
45
|
+
def is_scout_proxy_logger?
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
28
49
|
def method_missing(name, *args, &block)
|
29
50
|
# Some libraries will do stuff like Library.logger.formatter = Rails.logger.formatter
|
30
51
|
# As such, we should return the first logger's (the original logger) return value.
|
@@ -50,11 +50,11 @@ module ScoutApm
|
|
50
50
|
logger.formatter = log_instance.formatter
|
51
51
|
|
52
52
|
if ::Rails.env.development? && $stdout.tty? && $stderr.tty?
|
53
|
-
next if ActiveSupport::Logger.respond_to?(:logger_outputs_to?) && ActiveSupport::Logger.logger_outputs_to?(
|
53
|
+
next if ::ActiveSupport::Logger.respond_to?(:logger_outputs_to?) && ::ActiveSupport::Logger.logger_outputs_to?(
|
54
54
|
logger, $stdout, $stderr
|
55
55
|
)
|
56
56
|
|
57
|
-
logger.extend(ActiveSupport::Logger.broadcast(ActiveSupport::Logger.new($stdout)))
|
57
|
+
logger.extend(ActiveSupport::Logger.broadcast(::ActiveSupport::Logger.new($stdout)))
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# We start the monitor process outside the context of Rails, and ultimately don't use
|
4
|
+
# it for anything related to starting the collector. However, when we load the config/scout_apm.yml file,
|
5
|
+
# we support ERB, and users may be using Rails.env methods for naming the app, or configuring whether
|
6
|
+
# monitor should be enabled for a specific environment.
|
7
|
+
|
8
|
+
require 'active_support'
|
9
|
+
|
10
|
+
# https://github.com/rails/rails/blob/v7.2.1/railties/lib/rails.rb#L76
|
11
|
+
module Rails
|
12
|
+
class << self
|
13
|
+
def env
|
14
|
+
# EnvironmentInquirer was added in Rails 6.1
|
15
|
+
@env ||= if const_defined?('::ActiveSupport::EnvironmentInquirer')
|
16
|
+
::ActiveSupport::EnvironmentInquirer.new(ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || 'development')
|
17
|
+
else
|
18
|
+
::ActiveSupport::StringInquirer.new(ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || 'development')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -35,7 +35,7 @@ describe ScoutApm::Logging::Loggers::Capture do
|
|
35
35
|
capture = ScoutApm::Logging::Loggers::Capture.new(context)
|
36
36
|
capture.setup!
|
37
37
|
|
38
|
-
expect(TestLoggerWrapper.logger.
|
38
|
+
expect(TestLoggerWrapper.logger.respond_to?(:is_scout_proxy_logger?)).to eq(true)
|
39
39
|
|
40
40
|
TestLoggerWrapper.logger.info('TEST')
|
41
41
|
TestLoggerWrapper.logger.debug('SHOULD NOT CAPTURE')
|
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.12
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scout_apm
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/scout_apm/logging/loggers/swaps/rails.rb
|
95
95
|
- lib/scout_apm/logging/loggers/swaps/scout.rb
|
96
96
|
- lib/scout_apm/logging/loggers/swaps/sidekiq.rb
|
97
|
+
- lib/scout_apm/logging/monitor/_rails.rb
|
97
98
|
- lib/scout_apm/logging/monitor/collector/checksum.rb
|
98
99
|
- lib/scout_apm/logging/monitor/collector/configuration.rb
|
99
100
|
- lib/scout_apm/logging/monitor/collector/downloader.rb
|