zuora_connect 2.0.60t → 3.0.0k
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/Rakefile +1 -1
- data/app/controllers/zuora_connect/static_controller.rb +3 -7
- data/app/models/zuora_connect/app_instance_base.rb +90 -143
- data/config/initializers/postgresql_adapter.rb +1 -1
- data/config/initializers/prometheus.rb +13 -13
- data/config/initializers/redis.rb +4 -4
- data/config/initializers/resque.rb +0 -12
- data/config/initializers/unicorn.rb +2 -2
- data/config/routes.rb +0 -1
- data/lib/metrics/net.rb +7 -7
- data/lib/middleware/metrics_middleware.rb +9 -44
- data/lib/resque/plugins/app_instance_job.rb +10 -6
- data/lib/resque/plugins/custom_logger.rb +1 -1
- data/lib/zuora_connect.rb +3 -63
- data/lib/zuora_connect/controllers/helpers.rb +20 -20
- data/lib/zuora_connect/engine.rb +2 -1
- data/lib/zuora_connect/railtie.rb +0 -77
- data/lib/zuora_connect/version.rb +1 -1
- metadata +67 -14
- data/app/models/zuora_connect/telegraf.rb +0 -97
- data/lib/logging/connect_formatter.rb +0 -44
- data/lib/metrics/influx/point_value.rb +0 -79
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bad84d0fc35d26f517f83b2cc38e5d1569dafc4253c6c12a474f69aa9d9fee5e
|
4
|
+
data.tar.gz: 0ad1de0856425104abb6288662ca1481b097dfb3af696c40d1e8d5a1d018a0af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00dcd65d70b84242e2c298f1d663d98259083c53e4232cf00c477b32fb32d480a49a39bf982a5682807ee0ae828905cd6dfeb1f548bf6e1a501dd4aca58c63e
|
7
|
+
data.tar.gz: 91fe7a9815f2340879cc0a30ef405b48960d44b54f1a020f193c5f029448b19ddb513944ce424fde25764cc0b5bf9a25ae25f3b70d124d715f69e4304ebf36d3
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
15
15
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
16
|
end
|
17
17
|
|
18
|
-
APP_RAKEFILE = File.expand_path("../
|
18
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
19
19
|
load 'rails/tasks/engine.rake'
|
20
20
|
|
21
21
|
|
@@ -1,16 +1,12 @@
|
|
1
1
|
module ZuoraConnect
|
2
2
|
class StaticController < ApplicationController
|
3
|
-
before_action :authenticate_connect_app_request, :except => [:
|
4
|
-
before_action :clear_connect_app_session, :only => [:
|
5
|
-
after_action :persist_connect_app_session, :except => [:
|
3
|
+
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user]
|
4
|
+
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user]
|
5
|
+
after_action :persist_connect_app_session, :except => [:health, :initialize_app, :provision, :instance_user]
|
6
6
|
|
7
7
|
skip_before_action :verify_authenticity_token, :only => [:initialize_app, :provision]
|
8
8
|
http_basic_authenticate_with name: ENV['PROVISION_USER'], password: ENV['PROVISION_SECRET'], :only => [:provision, :instance_user]
|
9
9
|
|
10
|
-
def metrics
|
11
|
-
type = params[:type].present? ? params[:type] : "versions"
|
12
|
-
render json: ZuoraConnect::AppInstance.get_metrics(type).to_json, status: 200
|
13
|
-
end
|
14
10
|
|
15
11
|
def health
|
16
12
|
if params[:error].present?
|
@@ -12,7 +12,6 @@ module ZuoraConnect
|
|
12
12
|
|
13
13
|
self.table_name = "zuora_connect_app_instances"
|
14
14
|
attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message, :new_session_message, :connect_user, :logitems, :user_timezone
|
15
|
-
@@telegraf_host = nil
|
16
15
|
REFRESH_TIMEOUT = 2.minute #Used to determine how long to wait on current refresh call before executing another
|
17
16
|
INSTANCE_REFRESH_WINDOW = 1.hours #Used to set how how long till app starts attempting to refresh cached task connect data
|
18
17
|
INSTANCE_REDIS_CACHE_PERIOD = 24.hours #Used to determine how long to cached task data will live for
|
@@ -25,6 +24,8 @@ module ZuoraConnect
|
|
25
24
|
CATALOG_LOOKUP_CACHE_TIME_KEY = 'CatalogCachedAt'
|
26
25
|
CATALOG_LOOKUP_TTL = 60.seconds
|
27
26
|
CATALOG_LOOKUP_CACHE_RESULT_KEY = 'CatalogCache'
|
27
|
+
TIMEZONE_LOG_RATE_LIMIT_KEY = 'TimezoneLoggedAt'
|
28
|
+
TIMEZONE_LOG_PERIOD = 4.hours
|
28
29
|
IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh', 'de']
|
29
30
|
INTERNAL_HOSTS = []
|
30
31
|
LOGIN_TENANT_DESTINATION = 'target_login'
|
@@ -33,7 +34,7 @@ module ZuoraConnect
|
|
33
34
|
Aws::Errors::MissingCredentialsError,
|
34
35
|
Aws::S3::Errors::AccessDenied,
|
35
36
|
Aws::SES::Errors::AccessDenied,
|
36
|
-
Aws::KMS::Errors::AccessDeniedException
|
37
|
+
Aws::KMS::Errors::AccessDeniedException
|
37
38
|
].freeze
|
38
39
|
AWS_AUTH_ERRORS_MSG = "AWS Auth Errors".freeze
|
39
40
|
|
@@ -151,7 +152,8 @@ module ZuoraConnect
|
|
151
152
|
if ZuoraConnect.configuration.mode != "Production"
|
152
153
|
mock_task_data = {
|
153
154
|
"id" => ZuoraConnect.configuration.dev_mode_appinstance,
|
154
|
-
"mode" => ZuoraConnect.configuration.dev_mode_mode
|
155
|
+
"mode" => ZuoraConnect.configuration.dev_mode_mode,
|
156
|
+
"name" => "Developer Instance"
|
155
157
|
}
|
156
158
|
|
157
159
|
case ZuoraConnect.configuration.dev_mode_options.class
|
@@ -167,6 +169,7 @@ module ZuoraConnect
|
|
167
169
|
end
|
168
170
|
|
169
171
|
self.build_task(task_data: mock_task_data, session: session)
|
172
|
+
self.set_backup_creds if !self['zuora_logins'].present?
|
170
173
|
self.last_refresh = Time.now.to_i
|
171
174
|
else
|
172
175
|
time_expire = (session["#{self.id}::last_refresh"] || Time.now).to_i - INSTANCE_REFRESH_WINDOW.ago.to_i
|
@@ -245,48 +248,7 @@ module ZuoraConnect
|
|
245
248
|
ZuoraConnect.logger.error(ex) if !IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
246
249
|
end
|
247
250
|
|
248
|
-
|
249
|
-
sql = <<-eos
|
250
|
-
SELECT zuora_users.zuora_identity_response
|
251
|
-
FROM "#{self.id}".zuora_users
|
252
|
-
ORDER BY zuora_users.updated_at DESC
|
253
|
-
LIMIT 1;
|
254
|
-
eos
|
255
|
-
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
256
|
-
|
257
|
-
if user.present?
|
258
|
-
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
259
|
-
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
260
|
-
end
|
261
|
-
rescue => ex
|
262
|
-
Rails.logger.error('Failed to get users while setting app instance timezone', ex)
|
263
|
-
end
|
264
|
-
|
265
|
-
if self.user_timezone.present?
|
266
|
-
# connect instance which has a custom timezone
|
267
|
-
if !self.auto_deployed? && (
|
268
|
-
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
269
|
-
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
270
|
-
)
|
271
|
-
if self.environment == 'Production'
|
272
|
-
ZuoraConnect.logger.error(
|
273
|
-
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
274
|
-
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
275
|
-
app_instance_id: self.id
|
276
|
-
)
|
277
|
-
end
|
278
|
-
self.user_timezone = nil
|
279
|
-
Time.zone = self.timezone
|
280
|
-
else
|
281
|
-
begin
|
282
|
-
Time.zone = self.user_timezone
|
283
|
-
rescue ArgumentError
|
284
|
-
Time.zone = self.timezone
|
285
|
-
end
|
286
|
-
end
|
287
|
-
else
|
288
|
-
Time.zone = self.timezone
|
289
|
-
end
|
251
|
+
self.set_timezone
|
290
252
|
|
291
253
|
if self.task_data.present?
|
292
254
|
tenants = self.task_data.fetch('tenant_ids', [])
|
@@ -302,7 +264,7 @@ module ZuoraConnect
|
|
302
264
|
end
|
303
265
|
|
304
266
|
params = {
|
305
|
-
name: self.task_data.dig('name'),
|
267
|
+
name: self.task_data.dig('name'),
|
306
268
|
zuora_entity_ids: (self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities') || []).map{|e| e['id']}.uniq,
|
307
269
|
zuora_tenant_ids: tenants.map(&:to_s).uniq,
|
308
270
|
organizations: organizations
|
@@ -311,7 +273,7 @@ module ZuoraConnect
|
|
311
273
|
client = self.send(LOGIN_TENANT_DESTINATION).client
|
312
274
|
if defined?(client.rest_domain)
|
313
275
|
ZuoraConnect::RequestIdMiddleware.zuora_rest_domain = client.rest_domain
|
314
|
-
params.merge!({zuora_domain: client.rest_domain, environment: client.environment })
|
276
|
+
params.merge!({zuora_domain: client.rest_domain, environment: client.environment })
|
315
277
|
end
|
316
278
|
end
|
317
279
|
params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) || self[k] == v}
|
@@ -319,16 +281,77 @@ module ZuoraConnect
|
|
319
281
|
end
|
320
282
|
end
|
321
283
|
|
284
|
+
def set_timezone(timezone: self.timezone, type: :default)
|
285
|
+
if timezone.blank?
|
286
|
+
timezone = self.timezone
|
287
|
+
end
|
288
|
+
|
289
|
+
if type == :default
|
290
|
+
Time.zone = timezone
|
291
|
+
elsif type == :user
|
292
|
+
begin
|
293
|
+
sql = <<-eos
|
294
|
+
SELECT zuora_users.zuora_identity_response FROM "#{self.id}".zuora_users ORDER BY zuora_users.updated_at DESC LIMIT 1;
|
295
|
+
eos
|
296
|
+
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
297
|
+
|
298
|
+
if user.present?
|
299
|
+
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
300
|
+
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
301
|
+
else
|
302
|
+
if (Redis.current.hget(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id).to_i + TIMEZONE_LOG_PERIOD.to_i) <= Time.now.to_i
|
303
|
+
Rails.logger.error('Cannot find any user to set the timezone', app_instance_id: self.id)
|
304
|
+
Redis.current.hset(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id, Time.now.to_i)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
rescue => ex
|
308
|
+
Rails.logger.error('There is an error while getting timezone users', ex)
|
309
|
+
end
|
310
|
+
|
311
|
+
if self.user_timezone.present?
|
312
|
+
# connect instance which has a custom timezone
|
313
|
+
if !self.auto_deployed? && (
|
314
|
+
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
315
|
+
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
316
|
+
)
|
317
|
+
if self.environment == 'Production' &&
|
318
|
+
(Redis.current.hget(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id).to_i + TIMEZONE_LOG_PERIOD.to_i) <= Time.now.to_i
|
319
|
+
ZuoraConnect.logger.error(
|
320
|
+
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
321
|
+
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
322
|
+
app_instance_id: self.id
|
323
|
+
)
|
324
|
+
Redis.current.hset(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id, Time.now.to_i)
|
325
|
+
end
|
326
|
+
self.user_timezone = nil
|
327
|
+
Time.zone = timezone
|
328
|
+
else
|
329
|
+
begin
|
330
|
+
Time.zone = self.user_timezone
|
331
|
+
rescue ArgumentError
|
332
|
+
Rails.logger.error('Malformed user timezone', app_instance_id: self.id)
|
333
|
+
Time.zone = timezone
|
334
|
+
end
|
335
|
+
end
|
336
|
+
else
|
337
|
+
Time.zone = timezone
|
338
|
+
end
|
339
|
+
end
|
340
|
+
rescue => e
|
341
|
+
Rails.logger.error('Malformed timezone used', e, app_instance_id: self.id)
|
342
|
+
Time.zone = self.timezone
|
343
|
+
end
|
344
|
+
|
322
345
|
def auto_deployed?
|
323
346
|
self.id >= 25000000
|
324
347
|
end
|
325
348
|
|
326
|
-
def refresh(session: {})
|
349
|
+
def refresh(session: {})
|
327
350
|
refresh_count ||= 0
|
328
351
|
skip_connect ||= false
|
329
352
|
begin
|
330
353
|
#Check how app was deployed
|
331
|
-
if self.
|
354
|
+
if !self.auto_deployed? && !skip_connect
|
332
355
|
self.check_oauth_state
|
333
356
|
response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
|
334
357
|
|
@@ -340,16 +363,8 @@ module ZuoraConnect
|
|
340
363
|
end
|
341
364
|
|
342
365
|
self.build_task(task_data: parsed_json, session: session)
|
343
|
-
|
344
|
-
|
345
|
-
self.zuora_logins = self.strip_cache_data(object: parsed_json.dup, keys: ['applications', 'tokens', 'user_settings'])
|
346
|
-
self.save(:validate => false)
|
347
|
-
rescue Aws::KMS::Errors::ValidationException, *AWS_AUTH_ERRORS => ex
|
348
|
-
Rails.logger.warn(AWS_AUTH_ERRORS_MSG, ex)
|
349
|
-
rescue => ex
|
350
|
-
Rails.logger.error(AWS_AUTH_ERRORS_MSG, ex)
|
351
|
-
end
|
352
|
-
end
|
366
|
+
self.set_backup_creds
|
367
|
+
self.save(validate: false) if self.changed?
|
353
368
|
else
|
354
369
|
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Communicating with Connect", response.body, response.code)
|
355
370
|
end
|
@@ -394,8 +409,16 @@ module ZuoraConnect
|
|
394
409
|
end
|
395
410
|
|
396
411
|
#### START KMS ENCRYPTION Methods ####
|
412
|
+
def set_backup_creds
|
413
|
+
if self.kms_key.present? && self.kms_key.match(/^arn:aws:.*/) && self.task_data.present?
|
414
|
+
self.zuora_logins = self.strip_cache_data(object: self.task_data.dup, keys: ['applications', 'tokens', 'user_settings'])
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
397
418
|
def zuora_logins=(val)
|
398
419
|
write_attribute(:zuora_logins, kms_encrypt(val.to_json))
|
420
|
+
rescue Aws::KMS::Errors::ValidationException, Aws::KMS::Errors::NotFoundException, *AWS_AUTH_ERRORS => ex
|
421
|
+
Rails.logger.warn(AWS_AUTH_ERRORS_MSG, ex)
|
399
422
|
end
|
400
423
|
|
401
424
|
def zuora_logins
|
@@ -455,82 +478,6 @@ module ZuoraConnect
|
|
455
478
|
end
|
456
479
|
Thread.current[:appinstance] = self
|
457
480
|
end
|
458
|
-
|
459
|
-
def self.write_to_telegraf(*args)
|
460
|
-
if ZuoraConnect.configuration.enable_metrics && !defined?(Prometheus)
|
461
|
-
@@telegraf_host = ZuoraConnect::Telegraf.new() if @@telegraf_host == nil
|
462
|
-
unicorn_stats = self.unicorn_listener_stats() if defined?(Unicorn) && Unicorn.respond_to?(:listener_names)
|
463
|
-
@@telegraf_host.write(direction: 'Raindrops', tags: {}, values: unicorn_stats) unless unicorn_stats.blank?
|
464
|
-
return @@telegraf_host.write(*args)
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
def self.unicorn_listener_stats ()
|
469
|
-
stats_hash = {}
|
470
|
-
stats_hash["total_active"] = 0
|
471
|
-
stats_hash["total_queued"] = 0
|
472
|
-
|
473
|
-
begin
|
474
|
-
tmp = Unicorn.listener_names
|
475
|
-
unix = tmp.grep(%r{\A/})
|
476
|
-
tcp = tmp.grep(/\A.+:\d+\z/)
|
477
|
-
tcp = nil if tcp.empty?
|
478
|
-
unix = nil if unix.empty?
|
479
|
-
|
480
|
-
|
481
|
-
Raindrops::Linux.tcp_listener_stats(tcp).each do |addr,stats|
|
482
|
-
stats_hash["active_#{addr}"] = stats.active
|
483
|
-
stats_hash["queued_#{addr}"] = stats.queued
|
484
|
-
stats_hash["total_active"] = stats.active + stats_hash["total_active"]
|
485
|
-
stats_hash["total_queued"] = stats.queued + stats_hash["total_queued"]
|
486
|
-
end if tcp
|
487
|
-
|
488
|
-
Raindrops::Linux.unix_listener_stats(unix).each do |addr,stats|
|
489
|
-
stats_hash["active_#{addr}"] = stats.active
|
490
|
-
stats_hash["queued_#{addr}"] = stats.queued
|
491
|
-
stats_hash["total_active"] = stats.active + stats_hash["total_active"]
|
492
|
-
stats_hash["total_queued"] = stats.queued + stats_hash["total_queued"]
|
493
|
-
end if unix
|
494
|
-
rescue IOError => ex
|
495
|
-
rescue => ex
|
496
|
-
ZuoraConnect.logger.error(ex)
|
497
|
-
end
|
498
|
-
return stats_hash
|
499
|
-
end
|
500
|
-
|
501
|
-
def self.get_metrics(type)
|
502
|
-
@data = {}
|
503
|
-
|
504
|
-
if type == "versions"
|
505
|
-
@data = {
|
506
|
-
app_name: ZuoraConnect::Telegraf.app_name,
|
507
|
-
url: "dummy",
|
508
|
-
Version_Gem: ZuoraConnect::VERSION,
|
509
|
-
Version_Zuora: ZuoraAPI::VERSION ,
|
510
|
-
Version_Ruby: RUBY_VERSION,
|
511
|
-
Version_Rails: Rails.version,
|
512
|
-
hold: 1
|
513
|
-
}
|
514
|
-
elsif type == "stats"
|
515
|
-
begin
|
516
|
-
Resque.redis.ping
|
517
|
-
@resque = Resque.info
|
518
|
-
@data = {
|
519
|
-
app_name: ZuoraConnect::Telegraf.app_name,
|
520
|
-
url: "dummy",
|
521
|
-
Resque:{
|
522
|
-
Jobs_Finished: @resque[:processed] ,
|
523
|
-
Jobs_Failed: @resque[:failed],
|
524
|
-
Jobs_Pending: @resque[:pending],
|
525
|
-
Workers_Active: @resque[:working],
|
526
|
-
Workers_Total: @resque[:workers]
|
527
|
-
}
|
528
|
-
}
|
529
|
-
rescue
|
530
|
-
end
|
531
|
-
end
|
532
|
-
return @data
|
533
|
-
end
|
534
481
|
#### END Task Methods ####
|
535
482
|
|
536
483
|
#### START Task Methods ####
|
@@ -573,7 +520,7 @@ module ZuoraConnect
|
|
573
520
|
end
|
574
521
|
rescue ZuoraConnect::Exceptions::MissMatch => ex
|
575
522
|
raise
|
576
|
-
rescue ZuoraConnect::Exceptions::InvalidCredentialSet => ex
|
523
|
+
rescue ZuoraConnect::Exceptions::InvalidCredentialSet => ex
|
577
524
|
raise
|
578
525
|
rescue => ex
|
579
526
|
ZuoraConnect.logger.error("Build Task Error", ex)
|
@@ -629,12 +576,12 @@ module ZuoraConnect
|
|
629
576
|
self.refresh if !defined?(self.target_login)
|
630
577
|
|
631
578
|
response = HTTParty.get("#{ZuoraConnect.configuration.url}/api/#{self.api_version}/tenants/search?hostname=#{self.target_login.client.hostname}&node_id=#{self.zuora_entity_ids.first}")
|
632
|
-
|
579
|
+
|
633
580
|
if response.success?
|
634
581
|
parsed_json = JSON.parse(response.body)
|
635
|
-
|
582
|
+
|
636
583
|
#Set Org
|
637
|
-
if self.
|
584
|
+
if self.auto_deployed? && parsed_json['organization'].present?
|
638
585
|
login_cache = self.zuora_logins
|
639
586
|
login_cache.delete('organization')
|
640
587
|
self.zuora_logins = login_cache.merge({'organizations' => [parsed_json['organization']]})
|
@@ -654,7 +601,7 @@ module ZuoraConnect
|
|
654
601
|
end
|
655
602
|
end
|
656
603
|
self.save(:validate => false)
|
657
|
-
|
604
|
+
|
658
605
|
return parsed_json
|
659
606
|
end
|
660
607
|
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS + ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
@@ -708,7 +655,7 @@ module ZuoraConnect
|
|
708
655
|
end
|
709
656
|
|
710
657
|
def refresh_oauth
|
711
|
-
refresh_oauth_count ||= 0
|
658
|
+
refresh_oauth_count ||= 0
|
712
659
|
response = HTTParty.post("#{ZuoraConnect.configuration.url}/oauth/token", body: {
|
713
660
|
:grant_type => "refresh_token",
|
714
661
|
:redirect_uri => ZuoraConnect.configuration.oauth_client_redirect_uri,
|
@@ -1082,7 +1029,7 @@ module ZuoraConnect
|
|
1082
1029
|
catalog_container = catalog_container[object_id]
|
1083
1030
|
end
|
1084
1031
|
|
1085
|
-
return catalog_container
|
1032
|
+
return catalog_container || {}
|
1086
1033
|
end
|
1087
1034
|
|
1088
1035
|
if defined?(Redis.current) && object_id.present? && object_id.class == String && object_id.present?
|
@@ -1344,7 +1291,7 @@ module ZuoraConnect
|
|
1344
1291
|
|
1345
1292
|
def self.without_sticking
|
1346
1293
|
if self.connection.respond_to?(:without_sticking)
|
1347
|
-
self.connection.without_sticking do
|
1294
|
+
self.connection.without_sticking do
|
1348
1295
|
yield
|
1349
1296
|
end
|
1350
1297
|
else
|
@@ -26,7 +26,7 @@ module ActiveRecord
|
|
26
26
|
if oids
|
27
27
|
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
|
28
28
|
else
|
29
|
-
query += initializer.query_conditions_for_initial_load
|
29
|
+
query += initializer.query_conditions_for_initial_load
|
30
30
|
end
|
31
31
|
|
32
32
|
execute_and_clear(query, "SCHEMA", []) do |records|
|
@@ -49,10 +49,10 @@ if defined? Prometheus
|
|
49
49
|
prometheus = Prometheus::Client.registry
|
50
50
|
|
51
51
|
# Create your metrics.
|
52
|
-
ZUORA_VERSION = prometheus.gauge(:zuora_version, docstring: 'The current Zuora Gem version.', labels: %i(version name), preset_labels: { version: ZuoraAPI::VERSION, name:
|
53
|
-
CONNECT_VERSION = prometheus.gauge(:gem_version, docstring: 'The current Connect Gem version.', labels: %i(version name), preset_labels: { version: ZuoraConnect::VERSION, name:
|
54
|
-
RAILS_VERSION = prometheus.gauge(:rails_version, docstring: 'The current Rails version.', labels: %i(version name), preset_labels: { version: Rails.version, name:
|
55
|
-
RUBY_V = prometheus.gauge(:ruby_version, docstring: 'The current Ruby version.', labels: %i(version name), preset_labels: { version: RUBY_VERSION, name:
|
52
|
+
ZUORA_VERSION = prometheus.gauge(:zuora_version, docstring: 'The current Zuora Gem version.', labels: %i(version name), preset_labels: { version: ZuoraAPI::VERSION, name: ZuoraObservability::Env.app_name }, store_settings: most_recent_aggregation)
|
53
|
+
CONNECT_VERSION = prometheus.gauge(:gem_version, docstring: 'The current Connect Gem version.', labels: %i(version name), preset_labels: { version: ZuoraConnect::VERSION, name: ZuoraObservability::Env.app_name }, store_settings: most_recent_aggregation)
|
54
|
+
RAILS_VERSION = prometheus.gauge(:rails_version, docstring: 'The current Rails version.', labels: %i(version name), preset_labels: { version: Rails.version, name: ZuoraObservability::Env.app_name }, store_settings: most_recent_aggregation)
|
55
|
+
RUBY_V = prometheus.gauge(:ruby_version, docstring: 'The current Ruby version.', labels: %i(version name), preset_labels: { version: RUBY_VERSION, name: ZuoraObservability::Env.app_name }, store_settings: most_recent_aggregation)
|
56
56
|
|
57
57
|
ZUORA_VERSION.set(0)
|
58
58
|
CONNECT_VERSION.set(0)
|
@@ -61,12 +61,12 @@ if defined? Prometheus
|
|
61
61
|
|
62
62
|
# Do they have resque jobs?
|
63
63
|
if defined? Resque.redis
|
64
|
-
REDIS_CONNECTION = prometheus.gauge(:redis_connection, docstring: 'The status of the redis connection, 0 or 1', labels: %i(connection name), preset_labels: {connection:'redis', name:
|
65
|
-
JOBS_FINISHED = prometheus.gauge(:jobs_finished, docstring: 'Done resque jobs', labels: %i(type name), preset_labels: {type:'resque', name:
|
66
|
-
WORKERS_TOTAL = prometheus.gauge(:workers_total, docstring: 'Total resque workers', labels: %i(type name), preset_labels: {type:'resque', name:
|
67
|
-
WORKERS_ACTIVE = prometheus.gauge(:workers_active, docstring: 'Active resque workers', labels: %i(type name), preset_labels: {type:'resque', name:
|
68
|
-
JOBS_FAILED = prometheus.gauge(:jobs_failed, docstring: 'Failed resque jobs', labels: %i(type name), preset_labels: {type:'resque', name:
|
69
|
-
JOBS_PENDING = prometheus.gauge(:jobs_pending, docstring: 'Pending resque jobs', labels: %i(type name), preset_labels: {type:'resque', name:
|
64
|
+
REDIS_CONNECTION = prometheus.gauge(:redis_connection, docstring: 'The status of the redis connection, 0 or 1', labels: %i(connection name), preset_labels: {connection:'redis', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
65
|
+
JOBS_FINISHED = prometheus.gauge(:jobs_finished, docstring: 'Done resque jobs', labels: %i(type name), preset_labels: {type:'resque', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
66
|
+
WORKERS_TOTAL = prometheus.gauge(:workers_total, docstring: 'Total resque workers', labels: %i(type name), preset_labels: {type:'resque', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
67
|
+
WORKERS_ACTIVE = prometheus.gauge(:workers_active, docstring: 'Active resque workers', labels: %i(type name), preset_labels: {type:'resque', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
68
|
+
JOBS_FAILED = prometheus.gauge(:jobs_failed, docstring: 'Failed resque jobs', labels: %i(type name), preset_labels: {type:'resque', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
69
|
+
JOBS_PENDING = prometheus.gauge(:jobs_pending, docstring: 'Pending resque jobs', labels: %i(type name), preset_labels: {type:'resque', name: ZuoraObservability::Env.app_name}, store_settings: most_recent_aggregation)
|
70
70
|
end
|
71
71
|
|
72
72
|
if defined?(Unicorn) && Unicorn.respond_to?(:listener_names)
|
@@ -74,17 +74,17 @@ if defined? Prometheus
|
|
74
74
|
:unicorn_kills,
|
75
75
|
docstring: 'Unicorn Kills',
|
76
76
|
labels: %i(type name),
|
77
|
-
preset_labels: {type:'Unicorn-Killer', name:
|
77
|
+
preset_labels: {type:'Unicorn-Killer', name: ZuoraObservability::Env.app_name},
|
78
78
|
store_settings: sum_aggregation
|
79
79
|
)
|
80
80
|
|
81
|
-
|
81
|
+
ZuoraObservability::Metrics.unicorn_listener.each do |key, _|
|
82
82
|
gauge_name = "unicorn_#{key}".gsub(/[^a-zA-Z0-9_]/, '_')
|
83
83
|
gauge = prometheus.gauge(
|
84
84
|
gauge_name.to_sym,
|
85
85
|
docstring: 'Unicorn Stats',
|
86
86
|
labels: %i(type name),
|
87
|
-
preset_labels: { type: 'unicorn', name:
|
87
|
+
preset_labels: { type: 'unicorn', name: ZuoraObservability::Env.app_name },
|
88
88
|
store_settings: most_recent_aggregation
|
89
89
|
)
|
90
90
|
Prometheus.const_set(
|