zuora_observability 0.1.1 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b737913bb82aaa9107e1b6e143c488f40e284f392b50db8c7ebe295c29182d3
4
- data.tar.gz: a69de61e998011b53a88c9a1c1b1b742336b9f47c85b67bea3b60e05ef278e25
3
+ metadata.gz: 31ace19d3c6b8092e6faaf50da3bc94e53383bb9fa34dafaee16bfa5d5d6e555
4
+ data.tar.gz: 0f1761ca1c3c27fa4e42e626e689b2af9acb9b574bd6a0ce35f7b373f5f67f60
5
5
  SHA512:
6
- metadata.gz: dcd410016cab08896b3c687e52f7d2e7f9e987c9eaa402ffac539c1c3c6cdd61df13b7a7b758c55d165b4502d894adf43f3087d88999868a3a13c70ec51e5a0d
7
- data.tar.gz: b326d582ea811996cebb8a35430146141f8992fbeb83675bfda5067a4b08cb59714938d6fd0c98fa7f1ea1d8a0e63fbcb843e64c1dcf2da7d8ace5bdda2350b4
6
+ metadata.gz: e03d3fbabf4b6547844b28be303feeae46ea0966b793824b7fcafd4371551de5b436490abdf192f4046ac7ff38450e51b87b401de9e160e450d734510dba87b5
7
+ data.tar.gz: c36453840bd493eb29a6f1220a3ab234079b2795d97f32a201ddda9d445fd37c6e640fc147b53e6cc303dac72112b3ac2326daa8005a6ba20a4711c85ef86ca3
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ module TaggedLogging
5
+ # Patch to apply structured tags to Tagged Logs
6
+ module Formatter
7
+ def call(severity, timestamp, progname, data)
8
+ super(severity, timestamp, progname, merged_tags.merge(data))
9
+ end
10
+
11
+ private
12
+
13
+ def merged_tags
14
+ current_tags.reduce(:merge) || {}
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ module Rails
21
+ module Rack
22
+ # Patch to compute structured tags for Tagged Logging
23
+ class Logger
24
+ private
25
+
26
+ def compute_tags(request)
27
+ {
28
+ trace_id: request.uuid
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -11,7 +11,7 @@ module ZuoraObservability
11
11
 
12
12
  initializer(:rails_stdout_logging, before: :initialize_logger) do
13
13
  Rails.application.configure do
14
- config.logger = ZuoraObservability::Logger.custom_logger(name: 'Rails')
14
+ config.logger = ActiveSupport::TaggedLogging.new(ZuoraObservability::Logger.custom_logger(name: 'Rails'))
15
15
 
16
16
  next unless ZuoraObservability.configuration.json_logging
17
17
 
@@ -43,7 +43,7 @@ module ZuoraObservability
43
43
  private
44
44
 
45
45
  def app_parent_name
46
- if Rails::VERSION::MAJOR >= 6 && Rails::VERSION::MINOR >= 1
46
+ if Rails::VERSION::MAJOR >= 6
47
47
  Rails.application.class.module_parent_name
48
48
  else
49
49
  Rails.application.class.parent_name
@@ -59,6 +59,11 @@ module ZuoraObservability
59
59
  if type == :ougai
60
60
  logger = new($stdout, level: level, progname: name)
61
61
  else
62
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
63
+ Creating a non-ougai custom_logger is deprecated and will be removed
64
+ in a future version of zuora_observability.
65
+ MSG
66
+
62
67
  require 'mono_logger'
63
68
  logger = MonoLogger.new(STDOUT)
64
69
  logger.level = level
@@ -25,7 +25,6 @@ module ZuoraObservability
25
25
  items = {
26
26
  msg: 'Rails Request',
27
27
  params: event.payload[:params].as_json(except: IGNORE_PARAMS).to_s,
28
- trace_id: event.payload[:headers]['action_dispatch.request_id'],
29
28
  zuora_trace_id: event.payload[:headers]['HTTP_ZUORA_REQUEST_ID'],
30
29
  error: event.payload[:exception_object]
31
30
  }
@@ -50,18 +50,21 @@ module ZuoraObservability
50
50
  ecs: { version: ECS_VERSION },
51
51
  log: { level: severity, logger: progname || @app_name },
52
52
  service: { name: Env.name, version: Env.version },
53
- trace: { id: data[:trace_id] }
53
+ trace: { id: data[:trace_id] },
54
+ tags: ['zecs']
54
55
  }
55
56
  end
56
57
 
57
- # error
58
+ # errors
58
59
  def error_fields(data)
59
- return {} unless data[:error]
60
+ return {} unless data[:error] || data[:err]
61
+
62
+ error = data[:err] || serialize_exc(data[:error])
60
63
 
61
64
  {
62
- message: data[:error].message,
63
- stack_trace: data[:error].backtrace.join("\n"),
64
- type: data[:error].class
65
+ message: error[:message],
66
+ stack_trace: error[:stack],
67
+ type: error[:name]
65
68
  }.compact
66
69
  end
67
70
 
@@ -72,16 +75,21 @@ module ZuoraObservability
72
75
 
73
76
  # http.request
74
77
  def request_fields(data)
78
+ request = data.slice(:method, :params).merge(data.fetch(:request, {}))
79
+
75
80
  {
76
- method: data[:method],
77
- body: ({ content: data[:params] } if data.key? :params)
81
+ method: request[:method],
82
+ body: ({ content: request[:params] } if request.key? :params)
78
83
  }.compact
79
84
  end
80
85
 
81
86
  # http.response
82
87
  def response_fields(data)
88
+ response = data.slice(:status).merge(data.fetch(:response, {}))
89
+
83
90
  {
84
- status_code: data[:status]
91
+ status_code: response[:status],
92
+ body: ({ content: response[:params] } if response.key? :params),
85
93
  }.compact
86
94
  end
87
95
 
@@ -100,6 +108,7 @@ module ZuoraObservability
100
108
  # url
101
109
  def url_fields(data)
102
110
  {
111
+ full: data.dig(:url, :full),
103
112
  path: data[:path]
104
113
  }.compact
105
114
  end
@@ -145,7 +154,6 @@ module ZuoraObservability
145
154
 
146
155
  def base_fields(data)
147
156
  {
148
- apartment_id: data[:app_instance_id],
149
157
  cp_id: data[:zuora_track_id],
150
158
  environment: data[:environment],
151
159
  tenant_id: data[:tenant_ids],
@@ -155,16 +163,27 @@ module ZuoraObservability
155
163
 
156
164
  # zuora.http
157
165
  def http_fields(data)
158
- z_http_request = { headers: data[:headers] }.compact
166
+ z_http_request = {
167
+ headers: data[:headers] || data.dig(:request, :headers),
168
+ headers_blob: data.dig(:request, :headers_blob)
169
+ }.compact
170
+
171
+ z_http_response = {
172
+ headers: data.dig(:response, :headers),
173
+ headers_blob: data.dig(:response, :headers_blob)
174
+ }.compact
159
175
 
160
176
  {
161
- request: (z_http_request unless z_http_request.empty?)
177
+ request: (z_http_request unless z_http_request.empty?),
178
+ response: (z_http_response unless z_http_response.empty?)
162
179
  }.compact
163
180
  end
164
181
 
165
182
  # Service's Custom Fields
166
183
  def service_fields(data)
167
- data[:zecs_service].presence || {}
184
+ {
185
+ app_instance_id: data[:app_instance_id]
186
+ }.merge(data.fetch(:zecs_service, {})).compact
168
187
  end
169
188
  end
170
189
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZuoraObservability
4
- VERSION = '0.1.1'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_observability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hartley McGuire
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge
@@ -244,8 +244,6 @@ files:
244
244
  - MIT-LICENSE
245
245
  - README.md
246
246
  - Rakefile
247
- - app/assets/config/zuora_observability_manifest.js
248
- - app/assets/stylesheets/zuora_observability/application.css
249
247
  - app/controllers/zuora_observability/application_controller.rb
250
248
  - app/controllers/zuora_observability/metrics_controller.rb
251
249
  - app/helpers/zuora_observability/application_helper.rb
@@ -254,6 +252,7 @@ files:
254
252
  - app/models/zuora_observability/application_record.rb
255
253
  - app/views/layouts/zuora_observability/application.html.erb
256
254
  - config/initializers/loggers.rb
255
+ - config/initializers/tagged_logging.rb
257
256
  - config/routes.rb
258
257
  - lib/tasks/zuora_observability_tasks.rake
259
258
  - lib/zuora_observability.rb
@@ -284,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
283
  - !ruby/object:Gem::Version
285
284
  version: '0'
286
285
  requirements: []
287
- rubygems_version: 3.2.3
286
+ rubygems_version: 3.2.15
288
287
  signing_key:
289
288
  specification_version: 4
290
289
  summary: Summary of ZuoraObservability.
@@ -1 +0,0 @@
1
- //= link_directory ../stylesheets/zuora_observability .css
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */