zuora_connect 1.7.05 → 1.7.06

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a857c08845f7874d0e5993d6dcfd64b5f477a6b7
4
- data.tar.gz: 9b44889f84667d06f12eac95a99b89ee32de995c
3
+ metadata.gz: 84140eabcf1113abd7eeec18aaaf1ec0997fecc0
4
+ data.tar.gz: 9d88deb7f485ecc9796baee006482e167d6961c0
5
5
  SHA512:
6
- metadata.gz: 2d448ca83a052c5b045efb072642c7fa69290ced6ed63b83b4bce9d07821637f11eb1fea44cc9a2dc68093a9c5fd66e799ae09d2f92e14e5c7b2e189c16fd096
7
- data.tar.gz: 45a84690808ea9b2fad8506f7a07360f05adde3dfc4f649b7070e4bfd941bc7b012b587291b7a55a4907c3cc8fc824b279b69041cfefc0126e0a11fe7e95e4e3
6
+ metadata.gz: baedce094c2dfdfd25977d6bbbee9f619ad1b239d73dfb0cafd1b1506273b30bb4bc75ce55ff5f073034eb15ca692ca682428ca371f26cbe87d8aee8afbb26a9
7
+ data.tar.gz: 5db8d831c7c50a0762d3b012499ee7d870720bb54e047521d9ca20c4dde4416688602df89d3140a94dd6779f222cdfcb569982923b823c19204bc5af8f8e491a
@@ -469,20 +469,25 @@ module ZuoraConnect
469
469
  end
470
470
 
471
471
  def queue_paused?
472
- return Redis.current.get("resque:PauseQueue:#{self.id}").to_bool
472
+ return Redis.current.get("resque:PauseQueue:#{self.id}").present?
473
473
  end
474
474
 
475
- def queue_pause(time: nil)
475
+ def queue_pause(time: nil, current_user: 'Default')
476
476
  if time.present?
477
477
  raise "Time must be fixnum of seconds." if time.class != Fixnum
478
- Redis.current.setex("resque:PauseQueue:#{self.id}", time, true)
478
+ Redis.current.setex("resque:PauseQueue:#{self.id}", time, current_user)
479
479
  else
480
- Redis.current.set("resque:PauseQueue:#{self.id}", true)
480
+ Redis.current.set("resque:PauseQueue:#{self.id}", current_user)
481
481
  end
482
482
  end
483
483
 
484
- def queue_start
485
- Redis.current.del("resque:PauseQueue:#{self.id}")
484
+ def queue_start(current_user: 'Default')
485
+ paused_user = Redis.current.get("resque:PauseQueue:#{self.id}")
486
+ if paused_user == current_user || paused_user.blank?
487
+ Redis.current.del("resque:PauseQueue:#{self.id}")
488
+ else
489
+ raise "Can only unpause for user #{user}."
490
+ end
486
491
  end
487
492
  ### END Resque Helping Methods ####
488
493
 
@@ -29,7 +29,7 @@ module ZuoraConnect
29
29
  # To avoid writing metrics from rspec tests
30
30
  if Rails.env.to_sym != :test
31
31
  app_instance = Thread.current[:appinstance].present? ? Thread.current[:appinstance].id : 0
32
- tags = tags.merge({ app_name: app_name, process_type: process_type, app_instance: app_instance})
32
+ tags = tags.merge({ app_name: app_name, process_type: process_type, app_instance: app_instance, pod_name: pod_name})
33
33
 
34
34
  if direction == :inbound
35
35
  self.write_udp(series: INBOUND_METRICS_NAME, tags: tags, values: values) if INBOUND_METRICS
@@ -60,7 +60,11 @@ module ZuoraConnect
60
60
  end
61
61
 
62
62
  def app_name
63
- return ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}" : "#{Rails.application.class.parent_name}"
63
+ return ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : Rails.application.class.parent_name
64
+ end
65
+
66
+ def pod_name
67
+ return ENV['HOSTNAME'].present? ? ENV['HOSTNAME'] : 'Unknown'
64
68
  end
65
69
 
66
70
  # Returns the process type if any
@@ -1,5 +1,6 @@
1
1
  if defined?(Resque::Worker)
2
2
  Resque.send(:extend, Resque::Additions)
3
3
  Resque::Worker.send(:include, Resque::DynamicQueues)
4
+ Resque::Worker.send(:include, Resque::SilenceDone) if ZuoraConnect.configuration.silencer_resque_finish == true
4
5
  Resque::Job.send(:include, Resque::SelfLookup)
5
6
  end
@@ -0,0 +1,9 @@
1
+ if defined?(Unicorn::WorkerKiller)
2
+ Unicorn::WorkerKiller.module_eval do
3
+ self.singleton_class.send(:alias_method, :kill_self_old, :kill_self)
4
+ def self.kill_self(logger, start_time)
5
+ self.kill_self_old(logger, start_time)
6
+ ZuoraConnect::AppInstance.write_to_telegraf(direction: 'Unicorn-Killer', tags: { }, values: {kill: 1})
7
+ end
8
+ end
9
+ end
@@ -46,7 +46,11 @@ module Middleware
46
46
  @status, @headers, @response = @app.call(env)
47
47
 
48
48
  # If the url contains any CSS or JavaScript files then do not collect metrics for them
49
- return [@status, @headers, @response] if ["css", "assets", "jpg", "png", "jpeg", "ico"].any? { |word| env['PATH_INFO'].include?(word) }
49
+ if ["css", "assets", "jpg", "png", "jpeg", "ico"].any? { |word| env['PATH_INFO'].include?(word) } || /.*\.js$/.match(env['PATH_INFO'])
50
+ tags = {status: @status, controller: 'ActionController', action: 'Assets' }
51
+ values = {response_time: ((Time.now - start_time)*1000).round(2) }
52
+ ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: 'request-inbound-assets', tags: tags, values: values)
53
+ end
50
54
 
51
55
  if defined? Prometheus
52
56
  #Prometheus Stuff
@@ -0,0 +1,26 @@
1
+ module Resque
2
+ module SilenceDone
3
+ def perform_no_finish_log(job)
4
+ begin
5
+ if fork_per_job?
6
+ reconnect
7
+ run_hook :after_fork, job
8
+ end
9
+ job.perform
10
+ rescue Object => e
11
+ report_failed_job(job,e)
12
+ else
13
+ # log_with_severity :info, "done: #{job.inspect}"
14
+ ensure
15
+ yield job if block_given?
16
+ end
17
+ end
18
+
19
+ def self.included(receiver)
20
+ receiver.class_eval do
21
+ alias perform_with_finish_log perform
22
+ alias perform perform_no_finish_log
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/zuora_connect.rb CHANGED
@@ -6,6 +6,7 @@ require 'zuora_connect/views/helpers'
6
6
  require 'zuora_connect/railtie'
7
7
  require 'resque/additions'
8
8
  require 'resque/dynamic_queues'
9
+ require 'resque/silence_done'
9
10
  require 'resque/self_lookup'
10
11
  require 'metrics/influx/point_value'
11
12
  require 'metrics/net'
@@ -3,7 +3,7 @@ module ZuoraConnect
3
3
 
4
4
  attr_accessor :default_locale, :default_time_zone, :url, :mode, :delayed_job,:private_key, :additional_apartment_models
5
5
 
6
- attr_accessor :enable_metrics, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block
6
+ attr_accessor :enable_metrics, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish
7
7
 
8
8
  attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
9
9
 
@@ -17,8 +17,8 @@ module ZuoraConnect
17
17
  @delayed_job = false
18
18
  @private_key = ENV["CONNECT_KEY"]
19
19
  @additional_apartment_models = []
20
+ @silencer_resque_finish = true
20
21
 
21
-
22
22
  # Setting the app name for telegraf write
23
23
  @enable_metrics = false
24
24
  @telegraf_endpoint = 'udp://telegraf-app-metrics.monitoring.svc.cluster.local:8094'
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.7.05"
2
+ VERSION = "1.7.06"
3
3
  end
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.05
4
+ version: 1.7.06
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-07 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment
@@ -272,6 +272,7 @@ files:
272
272
  - config/initializers/redis.rb
273
273
  - config/initializers/resque.rb
274
274
  - config/initializers/to_bool.rb
275
+ - config/initializers/unicorn.rb
275
276
  - config/routes.rb
276
277
  - db/migrate/20100718151733_create_connect_app_instances.rb
277
278
  - db/migrate/20101024162319_add_tokens_to_app_instance.rb
@@ -289,6 +290,7 @@ files:
289
290
  - lib/resque/additions.rb
290
291
  - lib/resque/dynamic_queues.rb
291
292
  - lib/resque/self_lookup.rb
293
+ - lib/resque/silence_done.rb
292
294
  - lib/tasks/zuora_connect_tasks.rake
293
295
  - lib/zuora_connect.rb
294
296
  - lib/zuora_connect/configuration.rb
@@ -363,44 +365,44 @@ signing_key:
363
365
  specification_version: 4
364
366
  summary: Summary of Connect.
365
367
  test_files:
366
- - test/integration/navigation_test.rb
367
- - test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
368
- - test/models/zuora_connect/app_instance_test.rb
368
+ - test/test_helper.rb
369
369
  - test/lib/generators/zuora_connect/datatable_generator_test.rb
370
370
  - test/zuora_connect_test.rb
371
+ - test/models/zuora_connect/app_instance_test.rb
372
+ - test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
373
+ - test/integration/navigation_test.rb
371
374
  - test/fixtures/zuora_connect/app_instances.yml
372
375
  - test/dummy/Rakefile
373
- - test/dummy/config.ru
374
- - test/dummy/bin/setup
375
- - test/dummy/bin/rake
376
- - test/dummy/bin/bundle
377
- - test/dummy/bin/rails
376
+ - test/dummy/app/assets/stylesheets/application.css
377
+ - test/dummy/app/assets/javascripts/application.js
378
+ - test/dummy/app/views/layouts/application.html.erb
379
+ - test/dummy/app/controllers/application_controller.rb
380
+ - test/dummy/app/helpers/application_helper.rb
381
+ - test/dummy/config/application.rb
382
+ - test/dummy/config/boot.rb
383
+ - test/dummy/config/environments/development.rb
384
+ - test/dummy/config/environments/test.rb
385
+ - test/dummy/config/environments/production.rb
386
+ - test/dummy/config/database.yml
387
+ - test/dummy/config/routes.rb
388
+ - test/dummy/config/environment.rb
389
+ - test/dummy/config/locales/en.yml
378
390
  - test/dummy/config/initializers/filter_parameter_logging.rb
379
- - test/dummy/config/initializers/assets.rb
380
- - test/dummy/config/initializers/cookies_serializer.rb
391
+ - test/dummy/config/initializers/session_store.rb
381
392
  - test/dummy/config/initializers/inflections.rb
382
- - test/dummy/config/initializers/backtrace_silencers.rb
383
393
  - test/dummy/config/initializers/mime_types.rb
384
- - test/dummy/config/initializers/session_store.rb
385
394
  - test/dummy/config/initializers/wrap_parameters.rb
386
- - test/dummy/config/locales/en.yml
387
- - test/dummy/config/environments/production.rb
388
- - test/dummy/config/environments/test.rb
389
- - test/dummy/config/environments/development.rb
390
- - test/dummy/config/application.rb
391
- - test/dummy/config/routes.rb
392
- - test/dummy/config/environment.rb
395
+ - test/dummy/config/initializers/cookies_serializer.rb
396
+ - test/dummy/config/initializers/assets.rb
397
+ - test/dummy/config/initializers/backtrace_silencers.rb
393
398
  - test/dummy/config/secrets.yml
394
- - test/dummy/config/database.yml
395
- - test/dummy/config/boot.rb
396
- - test/dummy/README.rdoc
397
- - test/dummy/public/422.html
399
+ - test/dummy/config.ru
400
+ - test/dummy/bin/setup
401
+ - test/dummy/bin/bundle
402
+ - test/dummy/bin/rails
403
+ - test/dummy/bin/rake
398
404
  - test/dummy/public/500.html
399
- - test/dummy/public/favicon.ico
400
405
  - test/dummy/public/404.html
401
- - test/dummy/app/controllers/application_controller.rb
402
- - test/dummy/app/views/layouts/application.html.erb
403
- - test/dummy/app/assets/stylesheets/application.css
404
- - test/dummy/app/assets/javascripts/application.js
405
- - test/dummy/app/helpers/application_helper.rb
406
- - test/test_helper.rb
406
+ - test/dummy/public/422.html
407
+ - test/dummy/public/favicon.ico
408
+ - test/dummy/README.rdoc