semantic_logger_ecs_addon 0.1.11 → 0.1.15

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: e8352af461ec411f9248c88450b7a7740f67f6a645fe108f3392809e7ac7ac71
4
- data.tar.gz: 021a3c454c560442a1cc0a240b6c5cdb8a9e8f2f8134819094f99405d6dac0eb
3
+ metadata.gz: 6de6d3610f967c99762b807469d81909758aa27eec64991281ddec0825acc6dd
4
+ data.tar.gz: fdf7ca5413e9f41a3b521a2321b8fbf258d222343155991532c0a7fff45e4edc
5
5
  SHA512:
6
- metadata.gz: '09c1d3cddb5070315d393739fd083e0e16788c509c7f5ec29411b581d2cea865e494bec4215208ad2f10e404cd9c45ea419b8d6d07efe150587b179a9ec25762'
7
- data.tar.gz: dfe937ccff617890e4fa6a4854cfecc5d5b63a49173051629d49f273baf18830ddf3e577c11e82e26e1b55f638e8da26f19d08b08d485741ec1a8be348070263
6
+ metadata.gz: 77df9bbedd9cf76463a41c521fc10bbd806064f958a77ed0fa54af5751cc47fcf0c5ba63b84ebd6d3008227b0f6e6f1af057c0626e96be36416a88e9cd718c30
7
+ data.tar.gz: 06caa6e1d16ab15c73e33d0d510a6d8299bec9d4ee502d261d8b3581a2574b1d2d6a55b66b8296b10db5e4d28c2d34530117137372793040fd38c54df3f96687
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "request_store_rails"
4
+ require "semantic_logger"
5
+
3
6
  module RailsSemanticLogger
4
7
  module Sequel
5
8
  class LogSubscriber < ActiveSupport::LogSubscriber
@@ -9,20 +12,20 @@ module RailsSemanticLogger
9
12
 
10
13
  def self.runtime= value
11
14
  # ::ActiveRecord::RuntimeRegistry.sql_runtime = value
12
- RequestStore.store[:sql_runtime] = value
15
+ RequestLocals.store[:sql_runtime] = value
13
16
  end
14
17
 
15
18
  def self.runtime
16
19
  # ::ActiveRecord::RuntimeRegistry.sql_runtime ||= 0
17
- RequestStore.fetch(:sql_runtime) { 0 }
20
+ RequestLocals.fetch(:sql_runtime) { 0 }
18
21
  end
19
22
 
20
23
  def self.count= value
21
- RequestStore.store[:sql_count] = value
24
+ RequestLocals.store[:sql_count] = value
22
25
  end
23
26
 
24
27
  def self.count
25
- RequestStore.fetch(:sql_count) { 0 }
28
+ RequestLocals.fetch(:sql_count) { 0 }
26
29
  end
27
30
 
28
31
  def self.reset_runtime
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "semantic_logger/formatters/base"
4
+ require "semantic_logger_ecs_addon/utils/hash"
4
5
 
5
6
  module SemanticLoggerEcsAddon
6
7
  module Formatters
@@ -164,7 +165,7 @@ module SemanticLoggerEcsAddon
164
165
  end
165
166
 
166
167
  def format_payload
167
- if log.payload.respond_to?(:empty?) && !log.payload.empty?
168
+ if log.payload.respond_to?(:empty?) && !log.payload.empty? && log.payload.respond_to?(:has_key?)
168
169
  self.formatted_payload = Utils::Hash[**log.payload]
169
170
 
170
171
  rack_extract
@@ -176,11 +177,17 @@ module SemanticLoggerEcsAddon
176
177
  def request
177
178
  hash[:"http.request.id"] = formatted_payload.dig :request, :request_id
178
179
  hash[:"http.request.body.content"] = formatted_payload.dig :request, :body
180
+ if hash[:"http.request.body.content"].respond_to?(:to_json)
181
+ hash[:"http.request.body.content"] = hash[:"http.request.body.content"].to_json
182
+ end
179
183
  hash[:"http.request.method"] = formatted_payload.dig :request, :method
180
184
  end
181
185
 
182
186
  def response
183
187
  hash[:"http.response.body.content"] = formatted_payload.dig :response, :body
188
+ if hash[:"http.response.body.content"].respond_to?(:to_json)
189
+ hash[:"http.response.body.content"] = hash[:"http.response.body.content"].to_json
190
+ end
184
191
  hash[:"http.response.status_code"] = formatted_payload.dig :response, :status
185
192
  end
186
193
 
@@ -203,7 +210,7 @@ module SemanticLoggerEcsAddon
203
210
  def apm_agent_present_and_running?
204
211
  return false unless defined?(::ElasticAPM)
205
212
 
206
- ElasticAPM.running?
213
+ ::ElasticAPM.running?
207
214
  end
208
215
  end
209
216
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
3
+ require "oj"
4
+ require "semantic_logger_ecs_addon/formatters/raw"
4
5
 
5
6
  module SemanticLoggerEcsAddon
6
7
  module Formatters
@@ -12,7 +13,16 @@ module SemanticLoggerEcsAddon
12
13
 
13
14
  # Returns log messages in JSON format
14
15
  def call log, logger
15
- super(log, logger).to_json
16
+ Oj.dump(super(log, logger), nilnil: true, escape_mode: :json, mode: :rails)
17
+ rescue SystemStackError => _error
18
+ Oj.dump(
19
+ super(log, logger).transform_keys do |key|
20
+ key.to_s
21
+ end,
22
+ nilnil: true,
23
+ escape_mode: :json,
24
+ mode: :object
25
+ )
16
26
  end
17
27
  end
18
28
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "semantic_logger_ecs_addon/formatters/base"
4
+
3
5
  module SemanticLoggerEcsAddon
4
6
  module Formatters
5
7
  class Raw < Base
@@ -29,6 +31,8 @@ module SemanticLoggerEcsAddon
29
31
  root = root[:"error.cause"]
30
32
  end
31
33
  end
34
+ rescue SystemStackError => _error
35
+ root.merge! exception_hash exception
32
36
  end
33
37
 
34
38
  def event
@@ -81,10 +85,20 @@ module SemanticLoggerEcsAddon
81
85
  hash[:"user.domain"] = formatted_payload.dig :user, :type
82
86
  end
83
87
 
88
+ def safe_jsonify hash
89
+ hash.each do |k, v|
90
+ hash[k] = v.respond_to?(:to_json) ? v.to_json : v.inspect
91
+ rescue SystemStackError => _error
92
+ hash[k] = v.inspect
93
+ end
94
+ end
95
+
84
96
  def extras
85
- return unless formatted_payload.respond_to?(:empty?) && !formatted_payload.empty?
97
+ unless formatted_payload.respond_to?(:empty?) && !formatted_payload.empty? && formatted_payload.respond_to?(:has_key?)
98
+ return
99
+ end
86
100
 
87
- hash.merge! formatted_payload.except(:request, :response, :user)
101
+ hash.merge!(safe_jsonify(formatted_payload.except(:request, :response, :user)))
88
102
  end
89
103
 
90
104
  # Returns log messages in Hash format
@@ -5,7 +5,7 @@ module SemanticLoggerEcsAddon
5
5
  module Identity
6
6
  NAME = "semantic_logger_ecs_addon"
7
7
  LABEL = "Semantic Logger Ecs Addon"
8
- VERSION = "0.1.11"
8
+ VERSION = "0.1.15"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  SUMMARY = "A semantic logger formatter that formats the logs according to Elastic Common Schema, adds APM trace data if ElasticAPM is enabled and instruments sequel logs for rails if available."
11
11
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "pathname"
4
- require "zeitwerk"
5
-
6
- loader = Zeitwerk::Loader.for_gem
7
- loader.ignore "#{__dir__}/rails_semantic_logger"
8
- loader.ignore "#{__dir__}/sequel"
9
- loader.ignore "#{__dir__}/semantic_logger_ecs_addon/sequel.rb"
10
- loader.setup
4
+ require "semantic_logger_ecs_addon/utils/backtrace_cleaner"
5
+ require "semantic_logger_ecs_addon/utils/hash"
6
+ require "semantic_logger_ecs_addon/formatters/base"
7
+ require "semantic_logger_ecs_addon/formatters/json"
8
+ require "semantic_logger_ecs_addon/formatters/raw"
11
9
 
12
10
  # Main namespace.
13
11
  module SemanticLoggerEcsAddon
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/module/attr_internal"
4
- unless defined?(RailsSemanticLogger::Sequel::LogSubscriber)
5
- require_relative "../../rails_semantic_logger/sequel/log_subscriber"
6
- end
4
+ require "rails_semantic_logger/sequel/log_subscriber"
7
5
 
8
6
  module Sequel
9
7
  module Railties
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger_ecs_addon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
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qly
31
- dxZBuseVz7147l9amCG1fopHUpEkPSYznbOaKPyLCdSxfaKu9dwZQ1uF9DTIKGg6
32
- 16+iw7FZcVbyjw1KQTkYxPOaQcxwNCKQ+yVeICli6NoOinyzO4+onRG8fLOyREaW
33
- NGxVhaV01YqK1z7lZZoAuVWqbE1NMIO//5tvWC9slgKmWyuCc5YQCT3w+3sA4y82
34
- vYrYpx2LhW5Xd0nPdr4aI+5BUqGdI7Ypl3BqNHZljUUlieiWu7rU0MhIZgQ1lIMa
35
- pQreMxz5itbb+2KmpdBlkm8nuRoFv0jrL5LR+7+UBRknGsHXaEQQcQ==
27
+ aG9yaW9uMzAwNkBnbWFpbC5jb20wDQYJKoZIhvcNAQELBQADggGBANEGgdbZAeSN
28
+ 6NzJb0qO8Z/cd0QoPVjV5Bws9KUJHBrk8ldQWbk6vwrLxvYQgo5J8MTm80mqedfI
29
+ nuFWKBHXEUkzQc3zgRTXDnc6PwviSza/b/uh99Jra67GiTGiTB9XVNg+Wm1QX+SZ
30
+ I1LKIZNnySWiGKFCr3iPXw6Oj90G+vIjXpQ9lCAV/1FeKsxyuqURUD9ZDlhVyp32
31
+ agCjJz/VzVFo87BW8MYB1UlMJo5B9HKGG7jipzKlrfm683DYEwx/EnML/w7Lgryx
32
+ /u37RDsXpnnVpSaDaxL1HHMkuzxiMUGtYQk5KnJ21yRFn0ZAhavACArJj0/6zFdI
33
+ eomelpV08j/RaaK4j0w7TPHtB9zfLc4LG9AeGN/K97pZ2P5qteoezyhb4sdKulT+
34
+ KosCvruZx0i+xfBhrTh6f5uQ4T57DUvWiUcdHqv98HqAqyyiPuSiI46/yQgU/4D+
35
+ ApIuwzlhHr30wJqOI8K003+GUsnMkf/7aBmCfedz5dC1EF+2J2SCdg==
36
36
  -----END CERTIFICATE-----
37
- date: 2021-11-02 00:00:00.000000000 Z
37
+ date: 2022-01-19 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
- name: request_store
40
+ name: oj
41
41
  requirement: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: '1.5'
45
+ version: '3.13'
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '1.5'
52
+ version: '3.13'
53
53
  - !ruby/object:Gem::Dependency
54
- name: semantic_logger
54
+ name: request_store_rails
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '4.4'
59
+ version: '2.0'
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '4.4'
66
+ version: '2.0'
67
67
  - !ruby/object:Gem::Dependency
68
- name: zeitwerk
68
+ name: semantic_logger
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '2.4'
73
+ version: '4.4'
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: '2.4'
80
+ version: '4.4'
81
81
  description:
82
82
  email:
83
83
  - thorion3006@gmail.com
@@ -95,7 +95,7 @@ files:
95
95
  - lib/semantic_logger_ecs_addon/formatters/json.rb
96
96
  - lib/semantic_logger_ecs_addon/formatters/raw.rb
97
97
  - lib/semantic_logger_ecs_addon/identity.rb
98
- - lib/semantic_logger_ecs_addon/sequel.rb
98
+ - lib/semantic_logger_ecs_addon/sequel_rails.rb
99
99
  - lib/semantic_logger_ecs_addon/utils/backtrace_cleaner.rb
100
100
  - lib/semantic_logger_ecs_addon/utils/hash.rb
101
101
  - lib/sequel/database.rb
@@ -108,6 +108,7 @@ metadata:
108
108
  changelog_uri: https://github.com/thorion3006/semantic_logger_ecs_addon/blob/master/CHANGES.md
109
109
  documentation_uri: https://github.com/thorion3006/semantic_logger_ecs_addon
110
110
  source_code_uri: https://github.com/thorion3006/semantic_logger_ecs_addon
111
+ rubygems_mfa_required: 'true'
111
112
  post_install_message:
112
113
  rdoc_options: []
113
114
  require_paths:
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
128
129
  requirements: []
129
- rubygems_version: 3.2.22
130
+ rubygems_version: 3.2.32
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: A semantic logger formatter that formats the logs according to Elastic Common
metadata.gz.sig CHANGED
Binary file