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 +4 -4
- data/config/initializers/tagged_logging.rb +33 -0
- data/lib/zuora_observability/engine.rb +2 -0
- data/lib/zuora_observability/env.rb +1 -1
- data/lib/zuora_observability/logger.rb +5 -0
- data/lib/zuora_observability/logging/custom_options.rb +0 -1
- data/lib/zuora_observability/logging/formatter.rb +28 -19
- data/lib/zuora_observability/version.rb +1 -1
- metadata +4 -6
- data/app/jobs/zuora_observability/application_job.rb +0 -4
- data/app/mailers/zuora_observability/application_mailer.rb +0 -6
- data/app/models/zuora_observability/application_record.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c138e8fa24ec1a1bc4f348c5b03d9290d5ba1c82a23d31ee3893d2cd1ea3d99
|
4
|
+
data.tar.gz: 3d877492d7a316f48f7874429c23699a293cff8be5c2d72c07cf4342afb9ec77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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:
|
86
|
-
body: ({ content:
|
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:
|
94
|
-
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 = {
|
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
|
|
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.
|
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
|
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.
|
283
|
+
rubygems_version: 3.2.22
|
286
284
|
signing_key:
|
287
285
|
specification_version: 4
|
288
286
|
summary: Summary of ZuoraObservability.
|