zuora_connect 1.7.81t → 1.7.81u
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializers/resque.rb +2 -2
- data/lib/logging/connect_formatter.rb +39 -0
- data/lib/metrics/net.rb +1 -1
- data/lib/middleware/metrics_middleware.rb +1 -1
- data/lib/middleware/request_id_middleware.rb +14 -0
- data/lib/resque/plugins/custom_logger.rb +4 -23
- data/lib/zuora_connect.rb +28 -15
- data/lib/zuora_connect/railtie.rb +16 -10
- data/lib/zuora_connect/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b4bb8191e8f95e03e36b83ea4285544991f3de6884397704dd1a8206d3cd025
|
4
|
+
data.tar.gz: cafeffeea63dd77325f60e0d3ae440fef5dda0d31ebd6fbcc73913a477d3e7fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcf949c4cd5b0f2edf450a5b59db433c3103eee0ffa093b01f16447375385b860f50466e50c3b6913795f92d901c01731dff8cbc36360ac6747be7d1ce1e59a6
|
7
|
+
data.tar.gz: d6c26b7ac51022bd0b55197e7af41f9337c194ee451010c038e741f7866e3c7ba24986ab999e163fb7ee8b7e79c350963437b7f678c04b875906b0c40ca331d3
|
@@ -22,10 +22,10 @@ Resque.module_eval do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
if defined?(Resque)
|
25
|
-
Resque.logger = ZuoraConnect.custom_logger(name: "Resque")
|
25
|
+
Resque.logger = ZuoraConnect.custom_logger(name: "Resque", type: 'Monologger')
|
26
26
|
Resque::Scheduler.logger = ZuoraConnect.custom_logger(name: "ResqueScheduler") if defined?(Resque::Scheduler)
|
27
27
|
end
|
28
28
|
|
29
29
|
Makara::Logging::Logger.logger = ZuoraConnect.custom_logger(name: "Makara") if defined?(Makara)
|
30
30
|
ElasticAPM.agent.config.logger = ZuoraConnect.custom_logger(name: "ElasticAPM", level: MonoLogger::WARN) if defined?(ElasticAPM) && ElasticAPM.running?
|
31
|
-
ActionMailer::Base.logger = ZuoraConnect.custom_logger(name: "ActionMailer") if defined?(ActionMailer)
|
31
|
+
ActionMailer::Base.logger = ZuoraConnect.custom_logger(name: "ActionMailer", type: 'Monologger') if defined?(ActionMailer)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'ougai/formatters/base'
|
2
|
+
require 'ougai/formatters/for_json'
|
3
|
+
|
4
|
+
module Ougai
|
5
|
+
module Formatters
|
6
|
+
# A JSON formatter compatible with node-bunyan
|
7
|
+
class ConnectFormatter < Base
|
8
|
+
include ForJson
|
9
|
+
|
10
|
+
# Intialize a formatter
|
11
|
+
# @param [String] app_name application name (execution program name if nil)
|
12
|
+
# @param [String] hostname hostname (hostname if nil)
|
13
|
+
# @param [Hash] opts the initial values of attributes
|
14
|
+
# @option opts [String] :trace_indent (2) the value of trace_indent attribute
|
15
|
+
# @option opts [String] :trace_max_lines (100) the value of trace_max_lines attribute
|
16
|
+
# @option opts [String] :serialize_backtrace (true) the value of serialize_backtrace attribute
|
17
|
+
# @option opts [String] :jsonize (true) the value of jsonize attribute
|
18
|
+
# @option opts [String] :with_newline (true) the value of with_newline attribute
|
19
|
+
def initialize(app_name = nil, hostname = nil, opts = {})
|
20
|
+
aname, hname, opts = Base.parse_new_params([app_name, hostname, opts])
|
21
|
+
super(aname, hname, opts)
|
22
|
+
init_opts_for_json(opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
def _call(severity, time, progname, data)
|
26
|
+
dump({
|
27
|
+
name: progname || @app_name,
|
28
|
+
pid: $$,
|
29
|
+
level: severity,
|
30
|
+
timestamp: time.utc.strftime('%FT%T.%6NZ'),
|
31
|
+
}.merge(data.merge({message: data.delete(:msg)})))
|
32
|
+
end
|
33
|
+
|
34
|
+
def convert_time(data)
|
35
|
+
#data[:timestamp] = format_datetime(data[:time])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/metrics/net.rb
CHANGED
@@ -162,7 +162,7 @@ class HttpLogger
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def format_log_entry(message, dump = nil)
|
165
|
-
if self.class.colorize
|
165
|
+
if self.class.colorize && Rails.configuration.colorize_logging
|
166
166
|
message_color, dump_color = "4;32;1", "0;1"
|
167
167
|
log_entry = " \e[#{message_color}m#{message}\e[0m "
|
168
168
|
log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump
|
@@ -7,27 +7,8 @@ module Resque
|
|
7
7
|
module Plugins
|
8
8
|
module CustomLogger
|
9
9
|
def before_perform(*args)
|
10
|
-
|
11
|
-
|
12
|
-
logger = MonoLogger.new(STDOUT)
|
13
|
-
logger.level = Rails.application.config.log_level
|
14
|
-
logger.formatter = proc do |serverity, datetime, progname, msg|
|
15
|
-
begin
|
16
|
-
msg = JSON.parse(msg)
|
17
|
-
rescue JSON::ParserError => ex
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'json'
|
21
|
-
JSON.dump(
|
22
|
-
trace_id: marker,
|
23
|
-
level: serverity,
|
24
|
-
timestamp: datetime.strftime('%FT%T.%6N'),
|
25
|
-
pid: Process.pid,
|
26
|
-
msg: msg
|
27
|
-
) + "\n"
|
28
|
-
end
|
29
|
-
|
30
|
-
Rails.logger = logger
|
10
|
+
#Rails.logger = custom_logger(name: "RailsWorker", level: Rails.application.config.log_level)
|
11
|
+
Rails.logger.with_fields = { trace_id: SecureRandom.uuid }
|
31
12
|
case args.class.to_s
|
32
13
|
when "Array"
|
33
14
|
if args.first.class == Hash
|
@@ -38,8 +19,8 @@ module Resque
|
|
38
19
|
when "Hash"
|
39
20
|
data = args.merge({:worker_class => self.to_s})
|
40
21
|
end
|
41
|
-
Rails.logger.info(data.
|
22
|
+
Rails.logger.info(data.merge({:msg => 'Starting job'})) if data.present?
|
42
23
|
end
|
43
24
|
end
|
44
25
|
end
|
45
|
-
end
|
26
|
+
end
|
data/lib/zuora_connect.rb
CHANGED
@@ -9,6 +9,7 @@ require 'resque/dynamic_queues'
|
|
9
9
|
require 'resque/silence_done'
|
10
10
|
require 'resque/self_lookup'
|
11
11
|
require 'resque/plugins/custom_logger'
|
12
|
+
require 'logging/connect_formatter'
|
12
13
|
require 'metrics/influx/point_value'
|
13
14
|
require 'metrics/net'
|
14
15
|
|
@@ -25,24 +26,36 @@ module ZuoraConnect
|
|
25
26
|
@logger ||= custom_logger(name: "Connect", level: Rails.logger.level)
|
26
27
|
end
|
27
28
|
end
|
29
|
+
require 'ougai'
|
30
|
+
|
28
31
|
|
29
|
-
def custom_logger(name: "", level: Rails.logger.level)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def custom_logger(name: "", level: Rails.logger.present? ? Rails.logger.level : MonoLogger::INFO, type: :ougai)
|
33
|
+
if type == :ougai
|
34
|
+
require 'ougai'
|
35
|
+
#logger = Ougai::Logger.new(MonoLogger.new(STDOUT))
|
36
|
+
logger = Ougai::Logger.new(STDOUT)
|
37
|
+
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
|
38
|
+
logger.before_log = lambda do |data|
|
39
|
+
data[:trace_id] = ZuoraConnect::RequestIdMiddleware.request_id if ZuoraConnect::RequestIdMiddleware.request_id.present?
|
36
40
|
end
|
41
|
+
else
|
42
|
+
logger = MonoLogger.new(STDOUT)
|
43
|
+
logger.level = level
|
44
|
+
logger.formatter = proc do |serverity, datetime, progname, msg|
|
45
|
+
begin
|
46
|
+
msg = JSON.parse(msg)
|
47
|
+
rescue JSON::ParserError => ex
|
48
|
+
end
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
require 'json'
|
51
|
+
JSON.dump(
|
52
|
+
name: name,
|
53
|
+
level: serverity,
|
54
|
+
timestamp: datetime.strftime('%FT%T.%6NZ'),
|
55
|
+
pid: Process.pid,
|
56
|
+
message: name == "ActionMailer" ? msg.strip : msg
|
57
|
+
) + "\n"
|
58
|
+
end
|
46
59
|
end
|
47
60
|
return logger
|
48
61
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'middleware/metrics_middleware'
|
2
|
+
require 'middleware/request_id_middleware'
|
2
3
|
|
3
4
|
module ZuoraConnect
|
4
5
|
class Railtie < Rails::Railtie
|
@@ -22,24 +23,29 @@ module ZuoraConnect
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
initializer "zuora_connect.configure_rails_initialization" do |app|
|
25
|
-
app.middleware.insert_after Rack::Sendfile,
|
26
|
+
app.middleware.insert_after Rack::Sendfile, ZuoraConnect::MetricsMiddleware
|
27
|
+
app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
|
26
28
|
end
|
27
29
|
|
28
30
|
# hook to process_action
|
29
|
-
ActiveSupport::Notifications.subscribe('process_action.action_controller',
|
31
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller', ZuoraConnect::PageRequest.new)
|
30
32
|
|
31
33
|
initializer(:rails_stdout_logging, before: :initialize_logger) do
|
32
34
|
if Rails.env != 'development' && !ENV['DEIS_APP'].blank?
|
33
35
|
require 'lograge'
|
34
|
-
|
35
|
-
logger
|
36
|
-
|
37
|
-
# {severity: severity, time: datetime.strftime('%FT%T.%6N'), process_id: Process.pid, message: msg }.to_json
|
38
|
-
# end
|
39
|
-
Rails.configuration.logger = ActiveSupport::TaggedLogging.new(logger)
|
40
|
-
Rails.configuration.log_tags = [:uuid]
|
36
|
+
|
37
|
+
Rails.configuration.logger = ZuoraConnect.custom_logger(name: "Rails")
|
38
|
+
|
41
39
|
Rails.configuration.lograge.enabled = true
|
42
|
-
Rails.configuration.
|
40
|
+
Rails.configuration.colorize_logging = false
|
41
|
+
if Rails.configuration.logger.class.to_s == 'Ougai::Logger'
|
42
|
+
Rails.configuration.lograge.formatter = Class.new do |fmt|
|
43
|
+
def fmt.call(data)
|
44
|
+
{ msg: 'Request', request: data }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
#Rails.configuration.lograge.formatter = Lograge::Formatters::Json.new
|
43
49
|
Rails.configuration.lograge.custom_options = lambda do |event|
|
44
50
|
exceptions = %w(controller action format id)
|
45
51
|
items = {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.81u
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ougai
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: zuora_api
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,9 +318,11 @@ files:
|
|
304
318
|
- db/migrate/20110503003604_catalog_default.rb
|
305
319
|
- db/migrate/20180301052853_add_catalog_attempted_at.rb
|
306
320
|
- db/migrate/20181206162339_add_fields_to_instance.rb
|
321
|
+
- lib/logging/connect_formatter.rb
|
307
322
|
- lib/metrics/influx/point_value.rb
|
308
323
|
- lib/metrics/net.rb
|
309
324
|
- lib/middleware/metrics_middleware.rb
|
325
|
+
- lib/middleware/request_id_middleware.rb
|
310
326
|
- lib/resque/additions.rb
|
311
327
|
- lib/resque/dynamic_queues.rb
|
312
328
|
- lib/resque/plugins/custom_logger.rb
|