scout_apm_logging 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb4dc1a11fe63b4c983636958676d8ca7e76bb04c5281bdabd272373deaf83e5
4
- data.tar.gz: 70809502cbbfb93a9cc73e26329f4e52b57008f51f9e34b3769fdfb17b2d46f4
3
+ metadata.gz: a74ddd478e8429ef76315b9bdb23557583719b0ed241f0fecb1c0a6658b4efe7
4
+ data.tar.gz: 72bc063672bff254e893c196662c69cc06934297379e21ee3482e15974b4f465
5
5
  SHA512:
6
- metadata.gz: b3a17d497a14d952294dd23ce5eac8605f7cee5da807ba53cc312acafbe314c33a303d75d97ac828f3ea1aba40e733da1104aa655866121e7f3c149afc9935cb
7
- data.tar.gz: 3515ffc8593bc564318859e0fb7340f82c2c066509a82411091b8e5e21bb4abcb223e1318d83b76a12ac11986db22bf4abaec5f511d6c07bdcaa5cc32742b7fd
6
+ metadata.gz: 4f5ba120cff4d9087ce213736477eebb687159b126f415bf7e6ea2c3ddbf7b6058aa48b605f91031d4883af1b20019010a4f01ee6871b1fda79b5ff02cf29111
7
+ data.tar.gz: f029117cdc4d4b83d26dd5cbb67a9ac7f64fac72c67763d97bb6a712b3f566a0d9661a463c6f563b86aa18369e69188f6251e3c791035e6c737bc6155e5c2ae8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.5
2
+ * Remove `msg` attribute after it has been moved to the log body to prevent duplication.
3
+
4
+ ## 0.0.4
5
+ * Fix memoizing of log attributes, which could lead to persistent attributes.
6
+
1
7
  ## 0.0.3
2
8
  * **Feature**: Add support for TaggedLogging.
3
9
  * Add ability to customize file logger size. Increase default size to 10MiB.
@@ -12,12 +12,15 @@ module ScoutApm
12
12
  class Formatter < ::Logger::Formatter
13
13
  DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%LZ'
14
14
 
15
- def call(severity, time, progname, msg) # rubocop:disable Metrics/AbcSize
16
- attributes_to_log[:severity] = severity
17
- attributes_to_log[:time] = format_datetime(time)
15
+ def call(severity, time, progname, msg)
16
+ attributes_to_log = {
17
+ severity: severity,
18
+ time: format_datetime(time),
19
+ pid: Process.pid.to_s,
20
+ msg: msg2str(msg)
21
+ }
22
+
18
23
  attributes_to_log[:progname] = progname if progname
19
- attributes_to_log[:pid] = Process.pid.to_s
20
- attributes_to_log[:msg] = msg2str(msg)
21
24
  attributes_to_log['service.name'] = service_name
22
25
 
23
26
  attributes_to_log.merge!(scout_layer)
@@ -30,10 +33,6 @@ module ScoutApm
30
33
 
31
34
  private
32
35
 
33
- def attributes_to_log
34
- @attributes_to_log ||= {}
35
- end
36
-
37
36
  def format_datetime(time)
38
37
  time.utc.strftime(DATETIME_FORMAT)
39
38
  end
@@ -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:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ScoutApm
4
4
  module Logging
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.5'
6
6
  end
7
7
  end
@@ -48,6 +48,11 @@ describe ScoutApm::Logging do
48
48
  expect(messages.count('[YIELD] Yield Test')).to eq(1)
49
49
  expect(messages.count('Another Log')).to eq(1)
50
50
 
51
+ log_locations = lines.map { |item| item['log_location'] }.compact
52
+
53
+ # Verify that log attributes aren't persisted
54
+ expect(log_locations.size).to eq(1)
55
+
51
56
  # Kill the rails process. We use kill as using any other signal throws a long log line.
52
57
  Process.kill('KILL', rails_pid)
53
58
  # Kill the process and ensure PID file clean up
data/spec/rails/app.rb CHANGED
@@ -20,6 +20,7 @@ end
20
20
 
21
21
  class RootController < ActionController::Base
22
22
  def index
23
+ Rails.logger.warn('Add location log attributes')
23
24
  Rails.logger.tagged('TEST').info('Some log')
24
25
  Rails.logger.tagged('YIELD') { logger.info('Yield Test') }
25
26
  Rails.logger.info('Another Log')
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.3
4
+ version: 0.0.5
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-08 00:00:00.000000000 Z
11
+ date: 2024-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout_apm
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.0.8
149
+ rubygems_version: 3.1.6
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Ruby Logging Support