zuora_connect 1.7.50 → 1.7.51
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad59396c82c4d286dcf2b5afda3ad40983162f76
|
4
|
+
data.tar.gz: 9e527b969e5e4372b319cdd68d41ab48896a2ad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e73d775199745a4efdd392612e7ac4ee4fc9a9629f46f950aa34347070103757cb3aad668c5cb36e8cbfcf8c6fe9d9573bf0e729c2b6cc86e07c832443311bca
|
7
|
+
data.tar.gz: deb7f9b329ef3b7574aba311c44880d8c48fe1ff1ef008d2c1c721897b15c08807ac3a05482e876573e4c352ca2f04d6adb1935f312d241e3f70b69f3257c270
|
@@ -39,6 +39,7 @@ module ZuoraConnect
|
|
39
39
|
def initialize_redis_placeholder
|
40
40
|
if defined?(Redis.current)
|
41
41
|
Redis.current.zadd("APILimits", 9999999999, "placeholder")
|
42
|
+
Redis.current.zadd("InstanceRefreshing", 9999999999, "placeholder")
|
42
43
|
Resque.redis.zadd("PauseQueue", 9999999999, "placeholder")
|
43
44
|
end
|
44
45
|
end
|
@@ -414,23 +415,33 @@ module ZuoraConnect
|
|
414
415
|
|
415
416
|
#### START AppInstance Temporary Persistance Methods ####
|
416
417
|
def marked_for_refresh?
|
417
|
-
|
418
|
+
if defined?(Redis.current)
|
419
|
+
Redis.current.zremrangebyscore("InstanceRefreshing", "0", "(#{Time.now.to_i}")
|
420
|
+
return Redis.current.zscore("InstanceRefreshing", self.id).present?
|
421
|
+
else
|
422
|
+
return false
|
423
|
+
end
|
418
424
|
end
|
419
425
|
|
420
426
|
def reset_mark_for_refresh
|
421
|
-
Redis.current.
|
427
|
+
Redis.current.zrem("InstanceRefreshing", self.id) if defined?(Redis.current)
|
422
428
|
end
|
423
429
|
|
424
430
|
def reset_mark_refreshed_at
|
425
|
-
return defined?(Redis.current) ? REFRESH_TIMEOUT.to_i -
|
431
|
+
return defined?(Redis.current) ? REFRESH_TIMEOUT.to_i - reset_mark_expires_at : 0
|
426
432
|
end
|
427
433
|
|
428
434
|
def reset_mark_expires_at
|
429
|
-
|
435
|
+
if defined?(Redis.current)
|
436
|
+
refresh_time = Redis.current.zscore("InstanceRefreshing", self.id)
|
437
|
+
return refresh_time.present? ? (refresh_time - Time.now.to_i).round(0) : 0
|
438
|
+
else
|
439
|
+
return 0
|
440
|
+
end
|
430
441
|
end
|
431
442
|
|
432
443
|
def mark_for_refresh
|
433
|
-
return defined?(Redis.current) ? Redis.current.
|
444
|
+
return defined?(Redis.current) ? Redis.current.zadd("InstanceRefreshing", Time.now.to_i + REFRESH_TIMEOUT.to_i, self.id, {:nx => true}) : true
|
434
445
|
end
|
435
446
|
|
436
447
|
def data_lookup(session: {})
|
@@ -542,10 +553,8 @@ module ZuoraConnect
|
|
542
553
|
### START Resque Helping Methods ####
|
543
554
|
def api_limit(start: true, time: API_LIMIT_TIMEOUT.to_i)
|
544
555
|
if start
|
545
|
-
# Redis.current.setex("APILimits:#{self.id}", time, true)
|
546
556
|
Redis.current.zadd("APILimits", Time.now.to_i + time, self.id)
|
547
557
|
else
|
548
|
-
# Redis.current.del("APILimits:#{self.id}")
|
549
558
|
Redis.current.zrem("APILimits", self.id)
|
550
559
|
end
|
551
560
|
end
|
@@ -32,7 +32,12 @@ module ZuoraConnect
|
|
32
32
|
tags = { app_name: self.class.app_name, process_type: self.class.process_type, app_instance: app_instance, pod_name: self.class.pod_name}.merge(tags)
|
33
33
|
|
34
34
|
if direction == :inbound
|
35
|
-
|
35
|
+
if INBOUND_METRICS && !Thread.current[:inbound_metric].to_bool
|
36
|
+
self.write_udp(series: INBOUND_METRICS_NAME, tags: tags, values: values)
|
37
|
+
Thread.current[:inbound_metric] = true
|
38
|
+
else
|
39
|
+
return
|
40
|
+
end
|
36
41
|
elsif direction == :outbound
|
37
42
|
self.write_udp(series: OUTBOUND_METRICS_NAME, tags: tags, values: values) if OUTBOUND_METRICS
|
38
43
|
else
|
@@ -63,64 +63,69 @@ module Middleware
|
|
63
63
|
|
64
64
|
#Thread.current[:appinstance] = nil
|
65
65
|
start_time = Time.now
|
66
|
-
|
66
|
+
begin
|
67
|
+
@status, @headers, @response = @app.call(env)
|
68
|
+
ensure
|
69
|
+
|
70
|
+
# If the url contains any CSS or JavaScript files then do not collect metrics for them
|
71
|
+
if ["css", "assets", "jpg", "png", "jpeg", "ico"].any? { |word| env['PATH_INFO'].include?(word) } || /.*\.js$/.match(env['PATH_INFO'])
|
72
|
+
tags = {status: @status, controller: 'ActionController', action: 'Assets', app_instance: 0}
|
73
|
+
values = {response_time: ((Time.now - start_time)*1000).round(2) }
|
74
|
+
ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: 'request-inbound-assets', tags: tags, values: values)
|
75
|
+
end
|
67
76
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
values = {response_time: ((Time.now - start_time)*1000).round(2) }
|
72
|
-
ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: 'request-inbound-assets', tags: tags, values: values)
|
73
|
-
end
|
77
|
+
if defined? Prometheus
|
78
|
+
#Prometheus Stuff
|
79
|
+
if env['PATH_INFO'] == '/connect/internal/metrics'
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
#Do something before each scrape
|
82
|
+
if defined? Resque.redis
|
83
|
+
begin
|
78
84
|
|
79
|
-
|
80
|
-
if defined? Resque.redis
|
81
|
-
begin
|
85
|
+
Resque.redis.ping
|
82
86
|
|
83
|
-
|
87
|
+
Prometheus::REDIS_CONNECTION.set({connection:'redis',name: ZuoraConnect::Telegraf.app_name},1)
|
88
|
+
Prometheus::FINISHED_JOBS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:processed])
|
89
|
+
Prometheus::PENDING_JOBS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:pending])
|
90
|
+
Prometheus::ACTIVE_WORKERS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:working])
|
91
|
+
Prometheus::WORKERS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:workers])
|
92
|
+
Prometheus::FAILED_JOBS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:failed])
|
84
93
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
Prometheus::ACTIVE_WORKERS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:working])
|
89
|
-
Prometheus::WORKERS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:workers])
|
90
|
-
Prometheus::FAILED_JOBS.set({type:'resque',name: ZuoraConnect::Telegraf.app_name},Resque.info[:failed])
|
94
|
+
rescue Redis::CannotConnectError
|
95
|
+
Prometheus::REDIS_CONNECTION.set({connection:'redis',name: ZuoraConnect::Telegraf.app_name},0)
|
96
|
+
end
|
91
97
|
|
92
|
-
|
93
|
-
|
98
|
+
if ZuoraConnect.configuration.custom_prometheus_update_block != nil
|
99
|
+
ZuoraConnect.configuration.custom_prometheus_update_block.call()
|
100
|
+
end
|
94
101
|
end
|
95
102
|
|
96
|
-
if ZuoraConnect.configuration.custom_prometheus_update_block != nil
|
97
|
-
ZuoraConnect.configuration.custom_prometheus_update_block.call()
|
98
|
-
end
|
99
103
|
end
|
100
|
-
|
101
104
|
end
|
102
|
-
end
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
106
|
+
# Uncomment following block of code for handling engine requests/requests without controller
|
107
|
+
# else
|
108
|
+
# # Handling requests which do not have controllers (engines)
|
109
|
+
if env["SCRIPT_NAME"].present?
|
110
|
+
controller_path = "#{env['SCRIPT_NAME'][1..-1]}"
|
111
|
+
controller_path = controller_path.sub("/", "::")
|
112
|
+
request_path = "#{controller_path}#UnknownAction"
|
113
|
+
else
|
114
|
+
# Writing to telegraf: Handle 404
|
115
|
+
if [404, 500].include?(@status)
|
116
|
+
content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
|
117
|
+
content_type = content_type.gsub('text/javascript', 'application/javascript')
|
118
|
+
tags = {status: @status, content_type: content_type}
|
119
|
+
|
120
|
+
tags = tags.merge({controller: 'ActionController'})
|
121
|
+
tags = tags.merge({action: 'RoutingError' }) if @status == 404
|
122
|
+
|
123
|
+
values = {response_time: ((Time.now - start_time)*1000).round(2) }
|
124
|
+
|
125
|
+
ZuoraConnect::AppInstanceBase.write_to_telegraf(direction: :inbound, tags: tags, values: values)
|
126
|
+
end
|
123
127
|
end
|
128
|
+
Thread.current[:inbound_metric] = nil
|
124
129
|
end
|
125
130
|
[@status, @headers, @response]
|
126
131
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module ZuoraConnect
|
2
|
-
VERSION = "1.7.
|
3
|
-
end
|
2
|
+
VERSION = "1.7.51"
|
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.
|
4
|
+
version: 1.7.51
|
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-01-
|
11
|
+
date: 2019-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|