zuora_observability 0.1.1 → 0.3.1
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 +1 -1
- 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 +32 -13
- data/lib/zuora_observability/version.rb +1 -1
- metadata +4 -5
- data/app/assets/config/zuora_observability_manifest.js +0 -1
- data/app/assets/stylesheets/zuora_observability/application.css +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31ace19d3c6b8092e6faaf50da3bc94e53383bb9fa34dafaee16bfa5d5d6e555
|
4
|
+
data.tar.gz: 0f1761ca1c3c27fa4e42e626e689b2af9acb9b574bd6a0ce35f7b373f5f67f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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
|
-
#
|
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:
|
63
|
-
stack_trace:
|
64
|
-
type:
|
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:
|
77
|
-
body: ({ content:
|
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:
|
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 = {
|
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
|
-
|
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
|
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.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-
|
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.
|
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
|
-
*/
|