zuora_connect 3.0.0.pre.r → 3.0.0.pre.w
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 +4 -4
- data/config/initializers/resque.rb +4 -0
- data/config/initializers/zuora_observability.rb +13 -10
- data/lib/resque/plugins/app_instance_job.rb +8 -7
- data/lib/resque/plugins/custom_logger.rb +8 -9
- data/lib/zuora_connect/controllers/helpers.rb +7 -4
- data/lib/zuora_connect/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed4e56e9b8a6f0f2754499b3028838a0d92124512ef2a2245a24be0025a6fa71
|
4
|
+
data.tar.gz: 5f955b8f077522059306ed1ede3e50b2812e2c99e7acb3b513cbfb0cae40053b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca5517bfe7fe1b4519ce1e08667c8f9da100d94c498e83911d713c985def89e840fe5fda9bf758de922e20e1760c222c598bdd0e907b471a52c6238f5d498c6
|
7
|
+
data.tar.gz: dab92de50bde980687c88820a1953de9a9d5f86d2fefc9f38ce2e4c3dbfbf0479db7a8300a987dcc3ff3740d2b95e5ac88fd646f62b9e79ac4cf177337af93e3
|
@@ -5,6 +5,10 @@ if defined?(Resque::Worker)
|
|
5
5
|
Resque::Job.send(:include, Resque::SelfLookup)
|
6
6
|
end
|
7
7
|
|
8
|
+
if ENV['PROCESS_TYPE'] == 'worker'
|
9
|
+
Rails.logger = ZuoraObservability::Logger.custom_logger(name: 'RailsWorker', level: Logger::INFO)
|
10
|
+
end
|
11
|
+
|
8
12
|
Resque.module_eval do
|
9
13
|
# Returns a hash, mapping queue names to queue sizes
|
10
14
|
def queue_sizes
|
@@ -1,21 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
ZuoraObservability.configure do |config|
|
2
4
|
config.zecs_service_hook = lambda do |controller|
|
3
5
|
custom_payload = {}
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
appinstance = controller.instance_variable_get(:@appinstance)
|
7
|
+
|
8
|
+
if appinstance&.logitems.present? && appinstance.logitems.class == Hash
|
9
|
+
ActiveSupport::Deprecation.warn("logitems is deprecated, please use zecs_service_hook. See 'https://gitlab.zeta.tools/extension-products/incubating-projects/zuora_observability/-/blob/master/doc/logging.md' for more details.")
|
10
|
+
custom_payload.merge!(appinstance.logitems)
|
10
11
|
end
|
12
|
+
|
11
13
|
custom_payload
|
12
14
|
end
|
15
|
+
|
13
16
|
config.add_custom_payload_hook do |controller|
|
14
17
|
custom_payload = {}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
appinstance = controller.instance_variable_get(:@appinstance)
|
19
|
+
|
20
|
+
custom_payload.merge!({ email: appinstance.connect_user }) if appinstance
|
21
|
+
|
19
22
|
custom_payload
|
20
23
|
end
|
21
24
|
end
|
@@ -2,24 +2,25 @@ module Resque
|
|
2
2
|
module Plugins
|
3
3
|
module AppInstanceJob
|
4
4
|
def around_perform(args)
|
5
|
-
case args.class.
|
5
|
+
case args.class.name
|
6
6
|
when "Array"
|
7
|
-
if args.first.
|
7
|
+
if args.first.is_a?(Hash)
|
8
8
|
data = args.first.merge({:worker_class => self.to_s})
|
9
9
|
else
|
10
|
-
data = {:worker_class => self.to_s, :args => args}
|
10
|
+
data = {:worker_class => self.to_s, :args => args.to_json}
|
11
11
|
end
|
12
12
|
when "Hash"
|
13
13
|
data = args.merge({:worker_class => self.to_s})
|
14
14
|
end
|
15
|
+
|
15
16
|
if Rails.logger.is_a?(Ougai::Logger) && !Rails.env.development?
|
16
|
-
Rails.logger.with_fields = {
|
17
|
+
Rails.logger.with_fields = { zecs_service: data.transform_keys(&:to_sym), trace_id: SecureRandom.uuid }
|
17
18
|
end
|
18
19
|
|
19
20
|
begin
|
20
21
|
connection_count ||= 0
|
21
22
|
@appinstance = ZuoraConnect::AppInstance.find(args['app_instance_id'].to_i)
|
22
|
-
job_start_log
|
23
|
+
job_start_log
|
23
24
|
|
24
25
|
@appinstance.new_session(holding_pattern: true)
|
25
26
|
rescue ActiveRecord::RecordNotFound => exception
|
@@ -69,8 +70,8 @@ module Resque
|
|
69
70
|
Rails.logger.flush if Rails.logger.methods.include?(:flush)
|
70
71
|
end
|
71
72
|
|
72
|
-
def job_start_log
|
73
|
-
|
73
|
+
def job_start_log
|
74
|
+
Rails.logger.info('Starting job')
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
@@ -7,25 +7,24 @@ module Resque
|
|
7
7
|
module Plugins
|
8
8
|
module CustomLogger
|
9
9
|
def before_perform(*args)
|
10
|
-
case args.class.
|
10
|
+
case args.class.name
|
11
11
|
when "Array"
|
12
|
-
if args.first.
|
12
|
+
if args.first.is_a?(Hash)
|
13
13
|
data = args.first.merge({:worker_class => self.to_s})
|
14
14
|
else
|
15
|
-
data = {:worker_class => self.to_s, :args => args}
|
15
|
+
data = {:worker_class => self.to_s, :args => args.to_json}
|
16
16
|
end
|
17
17
|
when "Hash"
|
18
18
|
data = args.merge({:worker_class => self.to_s})
|
19
19
|
end
|
20
|
+
|
20
21
|
if Rails.logger.is_a?(Ougai::Logger) && !Rails.env.development?
|
21
|
-
Rails.logger.with_fields = {
|
22
|
-
end
|
23
|
-
data = {:msg => 'Starting job', :job => data}
|
24
|
-
if data.dig(:job, 'app_instance_id').present?
|
25
|
-
data[:app_instance_id] = data.dig(:job, 'app_instance_id')
|
22
|
+
Rails.logger.with_fields = { zecs_service: data.transform_keys(&:to_sym), trace_id: SecureRandom.uuid }
|
26
23
|
end
|
27
24
|
|
28
|
-
|
25
|
+
if data.present?
|
26
|
+
Rails.logger.info('Starting job')
|
27
|
+
end
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
@@ -19,6 +19,9 @@ module ZuoraConnect
|
|
19
19
|
ElasticAPM.set_label(:trace_id, request.uuid) if defined?(ElasticAPM) && ElasticAPM.running?
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
ZuoraConnect::ZuoraUser.current_user_id = request.headers["Zuora-User-Id"]
|
24
|
+
|
22
25
|
if request.headers["API-Token"].present?
|
23
26
|
@appinstance = ZuoraConnect::AppInstance.find_by(:api_token => request.headers["API-Token"])
|
24
27
|
ZuoraConnect.logger.debug("API REQUEST - API token") if @appinstance.present?
|
@@ -408,7 +411,7 @@ module ZuoraConnect
|
|
408
411
|
appinstances ||= ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host", entities: [zuora_entity_id], host: zuora_client.rest_domain).pluck(:id, :name)
|
409
412
|
end
|
410
413
|
|
411
|
-
zuora_user_id = cookies['Zuora-User-Id'] || session["ZuoraCurrentIdentity"]['userId']
|
414
|
+
zuora_user_id = cookies['Zuora-User-Id'] || session["ZuoraCurrentIdentity"]['userId'] || request.headers["Zuora-User-Id"]
|
412
415
|
|
413
416
|
if appinstances.size == 1
|
414
417
|
ZuoraConnect.logger.debug("Instance is #{appinstances.to_h.keys.first}")
|
@@ -547,11 +550,11 @@ module ZuoraConnect
|
|
547
550
|
final_error = output_xml.xpath('//fns:FaultCode', 'fns' =>'http://fault.api.zuora.com/').text
|
548
551
|
session.clear
|
549
552
|
if final_error.blank?
|
550
|
-
ZuoraConnect.logger.warn("UI Authorization Error", ex,
|
553
|
+
ZuoraConnect.logger.warn("UI Authorization Error", ex, response_body: response.body)
|
551
554
|
elsif final_error != "INVALID_SESSION"
|
552
|
-
ZuoraConnect.logger.warn("UI Authorization Error", ex,
|
555
|
+
ZuoraConnect.logger.warn("UI Authorization Error", ex, err: { name: final_error })
|
553
556
|
else
|
554
|
-
ZuoraConnect.logger.info("UI Authorization Error", ex,
|
557
|
+
ZuoraConnect.logger.info("UI Authorization Error", ex, err: { name: final_error })
|
555
558
|
end
|
556
559
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{request.fullpath}"
|
557
560
|
return
|
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: 3.0.0.pre.
|
4
|
+
version: 3.0.0.pre.w
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -430,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
430
430
|
- !ruby/object:Gem::Version
|
431
431
|
version: 1.3.1
|
432
432
|
requirements: []
|
433
|
-
rubygems_version: 3.2.
|
433
|
+
rubygems_version: 3.2.15
|
434
434
|
signing_key:
|
435
435
|
specification_version: 4
|
436
436
|
summary: Summary of Connect.
|