zuora_observability 0.2.2 → 0.3.3

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: f6d0f3a139bf8fb34c6d9eb5cda9f00e70454dca7eca5d5d805a1c5e3fd63db8
4
- data.tar.gz: 0deaaad02637351504969a88c05156944aff6121f06af6ea092662591828911c
3
+ metadata.gz: 4c138e8fa24ec1a1bc4f348c5b03d9290d5ba1c82a23d31ee3893d2cd1ea3d99
4
+ data.tar.gz: 3d877492d7a316f48f7874429c23699a293cff8be5c2d72c07cf4342afb9ec77
5
5
  SHA512:
6
- metadata.gz: 37bd27174e6e17457f24bdbecda6684de98a33a959403943ee02731cf763519b4cae6daa06ae1c58ca8f0ddb02924e1178c191a5170577f70e0112700a18cab9
7
- data.tar.gz: 6c75b2300f11d99fc8f94e88cb618e6da59ee686c51fed7b78a1a8e0b12972a613422cba1ae21ed26d686279d9c7f0802fa52a6c53955172aca651cfe4794851
6
+ metadata.gz: e70ddf07824d1a18edf90306696e27b686b48a1af4cb50a4f42ba3ee0fa1c43d5a55553a1e2d5bad1deca9b88e9fc94320fc37e6157f64aded958293988923a5
7
+ data.tar.gz: 71c1eb29ea25f069495c69165b090b6650a615668219dc732b7421a4873ee659ca75331b8aa68bc679b6d1a00dc41e687e62f06e8fa75cd197803edefc3feb88
@@ -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
@@ -15,6 +15,8 @@ module ZuoraObservability
15
15
 
16
16
  next unless ZuoraObservability.configuration.json_logging
17
17
 
18
+ config.logger = ActiveSupport::TaggedLogging.new(config.logger)
19
+
18
20
  require 'lograge'
19
21
  require 'zuora_observability/logging/custom_options'
20
22
 
@@ -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
  }
@@ -59,19 +59,13 @@ module ZuoraObservability
59
59
  def error_fields(data)
60
60
  return {} unless data[:error] || data[:err]
61
61
 
62
- if data[:error]
63
- {
64
- message: data[:error].message,
65
- stack_trace: data[:error].backtrace.join("\n"),
66
- type: data[:error].class
67
- }.compact
68
- else
69
- {
70
- message: data.dig(:err, :message),
71
- stack_trace: data.dig(:err, :stack),
72
- type: data.dig(:err, :name)
73
- }.compact
74
- end
62
+ error = data[:err] || serialize_exc(data[:error])
63
+
64
+ {
65
+ message: error[:message],
66
+ stack_trace: error[:stack],
67
+ type: error[:name]
68
+ }.compact
75
69
  end
76
70
 
77
71
  # http
@@ -81,17 +75,21 @@ module ZuoraObservability
81
75
 
82
76
  # http.request
83
77
  def request_fields(data)
78
+ request = data.slice(:method, :params).merge(data.fetch(:request, {}))
79
+
84
80
  {
85
- method: data[:method],
86
- body: ({ content: data[:params] } if data.key? :params)
81
+ method: request[:method],
82
+ body: ({ content: request[:params] } if request.key? :params)
87
83
  }.compact
88
84
  end
89
85
 
90
86
  # http.response
91
87
  def response_fields(data)
88
+ response = data.slice(:status).merge(data.fetch(:response, {}))
89
+
92
90
  {
93
- status_code: data[:status],
94
- body: data[:response_body]
91
+ status_code: response[:status],
92
+ body: ({ content: response[:params] } if response.key? :params),
95
93
  }.compact
96
94
  end
97
95
 
@@ -110,6 +108,7 @@ module ZuoraObservability
110
108
  # url
111
109
  def url_fields(data)
112
110
  {
111
+ full: data.dig(:url, :full),
113
112
  path: data[:path]
114
113
  }.compact
115
114
  end
@@ -156,6 +155,7 @@ module ZuoraObservability
156
155
  def base_fields(data)
157
156
  {
158
157
  cp_id: data[:zuora_track_id],
158
+ entity_ids: data[:entity_ids],
159
159
  environment: data[:environment],
160
160
  tenant_id: data[:tenant_ids],
161
161
  trace_id: data[:zuora_trace_id]
@@ -164,10 +164,19 @@ module ZuoraObservability
164
164
 
165
165
  # zuora.http
166
166
  def http_fields(data)
167
- z_http_request = { headers: data[:headers] }.compact
167
+ z_http_request = {
168
+ headers: data[:headers] || data.dig(:request, :headers),
169
+ headers_blob: data.dig(:request, :headers_blob)
170
+ }.compact
171
+
172
+ z_http_response = {
173
+ headers: data.dig(:response, :headers),
174
+ headers_blob: data.dig(:response, :headers_blob)
175
+ }.compact
168
176
 
169
177
  {
170
- request: (z_http_request unless z_http_request.empty?)
178
+ request: (z_http_request unless z_http_request.empty?),
179
+ response: (z_http_response unless z_http_response.empty?)
171
180
  }.compact
172
181
  end
173
182
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZuoraObservability
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.3'
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.2.2
4
+ version: 0.3.3
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-04-16 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge
@@ -247,11 +247,9 @@ files:
247
247
  - app/controllers/zuora_observability/application_controller.rb
248
248
  - app/controllers/zuora_observability/metrics_controller.rb
249
249
  - app/helpers/zuora_observability/application_helper.rb
250
- - app/jobs/zuora_observability/application_job.rb
251
- - app/mailers/zuora_observability/application_mailer.rb
252
- - app/models/zuora_observability/application_record.rb
253
250
  - app/views/layouts/zuora_observability/application.html.erb
254
251
  - config/initializers/loggers.rb
252
+ - config/initializers/tagged_logging.rb
255
253
  - config/routes.rb
256
254
  - lib/tasks/zuora_observability_tasks.rake
257
255
  - lib/zuora_observability.rb
@@ -282,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
280
  - !ruby/object:Gem::Version
283
281
  version: '0'
284
282
  requirements: []
285
- rubygems_version: 3.2.15
283
+ rubygems_version: 3.2.22
286
284
  signing_key:
287
285
  specification_version: 4
288
286
  summary: Summary of ZuoraObservability.
@@ -1,4 +0,0 @@
1
- module ZuoraObservability
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module ZuoraObservability
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module ZuoraObservability
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end