zuora_connect 1.7.81z → 1.7.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/zuora_connect/static_controller.rb +0 -13
- data/app/models/zuora_connect/app_instance_base.rb +39 -39
- data/app/models/zuora_connect/telegraf.rb +7 -11
- data/config/initializers/elastic_apm.rb +25 -0
- data/config/initializers/resque.rb +1 -10
- data/config/initializers/unicorn.rb +1 -2
- data/lib/metrics/net.rb +2 -2
- data/lib/middleware/metrics_middleware.rb +1 -1
- data/lib/resque/plugins/custom_logger.rb +24 -5
- data/lib/zuora_connect.rb +0 -104
- data/lib/zuora_connect/configuration.rb +2 -1
- data/lib/zuora_connect/controllers/helpers.rb +16 -15
- data/lib/zuora_connect/engine.rb +1 -0
- data/lib/zuora_connect/railtie.rb +14 -20
- data/lib/zuora_connect/version.rb +1 -1
- metadata +28 -28
- data/lib/logging/connect_formatter.rb +0 -39
- data/lib/middleware/request_id_middleware.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26ce5d94fddf03ecdd850c64680dd882002cc4ca
|
4
|
+
data.tar.gz: d0a19c0e885f3ee1ee5e7fab5a0f92f40964d1b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5df9a71214c6d19c2b16c7b67a3f516953915479c389ecb39617cac8b977ef89cfeeffbf0012da89f74bc22862ef3d2528da600db1ee9211ed0f00af9483771
|
7
|
+
data.tar.gz: a6775bfbf6a52391ba15ef53c431f93f4264d4068cf07bbef5aabd67f44658add9680c4f118a7945f1ef9332f4c785b7147b8914423af95515ccfce17c6bb14a
|
@@ -26,19 +26,6 @@ module ZuoraConnect
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def health
|
29
|
-
if params[:error].present?
|
30
|
-
begin
|
31
|
-
raise ZuoraConnect::Exceptions::Error.new('This is an error')
|
32
|
-
rescue => ex
|
33
|
-
case params[:error]
|
34
|
-
when 'Log'
|
35
|
-
Rails.logger.error(ex)
|
36
|
-
when 'Exception'
|
37
|
-
raise
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
29
|
render json: {
|
43
30
|
message: "Alive",
|
44
31
|
status: 200
|
@@ -27,7 +27,7 @@ module ZuoraConnect
|
|
27
27
|
self.attr_builder("timezone", ZuoraConnect.configuration.default_time_zone)
|
28
28
|
self.attr_builder("locale", ZuoraConnect.configuration.default_locale)
|
29
29
|
PaperTrail.whodunnit = "Backend" if defined?(PaperTrail)
|
30
|
-
if defined?(ElasticAPM)
|
30
|
+
if defined?(ElasticAPM)
|
31
31
|
ElasticAPM.set_user("Backend")
|
32
32
|
ElasticAPM.set_tag(:app_instance, self.id)
|
33
33
|
end
|
@@ -93,7 +93,7 @@ module ZuoraConnect
|
|
93
93
|
self.last_refresh = session["#{self.id}::last_refresh"]
|
94
94
|
self.connect_user = session["#{self.id}::user::email"] if session["#{self.id}::user::email"].present?
|
95
95
|
PaperTrail.whodunnit = self.connect_user if defined?(PaperTrail)
|
96
|
-
ElasticAPM.set_user(self.connect_user) if defined?(ElasticAPM)
|
96
|
+
ElasticAPM.set_user(self.connect_user) if defined?(ElasticAPM)
|
97
97
|
recoverable_session = false
|
98
98
|
|
99
99
|
## DEV MODE TASK DATA MOCKUP
|
@@ -120,26 +120,26 @@ module ZuoraConnect
|
|
120
120
|
|
121
121
|
if session.empty?
|
122
122
|
self.new_session_message = "REFRESHING - Session Empty"
|
123
|
-
|
123
|
+
Rails.logger.add(log_level, self.new_session_message)
|
124
124
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
125
125
|
self.refresh(session: session)
|
126
126
|
|
127
127
|
elsif (self.id != session["appInstance"].to_i)
|
128
128
|
self.new_session_message = "REFRESHING - AppInstance ID(#{self.id}) does not match session id(#{session["appInstance"].to_i})"
|
129
|
-
|
129
|
+
Rails.logger.add(log_level, self.new_session_message)
|
130
130
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
131
131
|
self.refresh(session: session)
|
132
132
|
|
133
133
|
elsif session["#{self.id}::task_data"].blank?
|
134
134
|
self.new_session_message = "REFRESHING - Task Data Blank"
|
135
|
-
|
135
|
+
Rails.logger.add(log_level, self.new_session_message)
|
136
136
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
137
137
|
self.refresh(session: session)
|
138
138
|
|
139
139
|
elsif session["#{self.id}::last_refresh"].blank?
|
140
140
|
self.new_session_message = "REFRESHING - No Time on Cookie"
|
141
141
|
recoverable_session = true
|
142
|
-
|
142
|
+
Rails.logger.add(log_level, self.new_session_message)
|
143
143
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
144
144
|
self.refresh(session: session)
|
145
145
|
|
@@ -147,7 +147,7 @@ module ZuoraConnect
|
|
147
147
|
elsif (session["#{self.id}::last_refresh"].to_i < INSTANCE_REFRESH_WINDOW.ago.to_i) && self.mark_for_refresh
|
148
148
|
self.new_session_message = "REFRESHING - Session Old by #{time_expire.abs} second"
|
149
149
|
recoverable_session = true
|
150
|
-
|
150
|
+
Rails.logger.add(log_level, self.new_session_message)
|
151
151
|
self.refresh(session: session)
|
152
152
|
|
153
153
|
else
|
@@ -156,14 +156,14 @@ module ZuoraConnect
|
|
156
156
|
else
|
157
157
|
self.new_session_message = "REBUILDING - Expires in #{time_expire} seconds"
|
158
158
|
end
|
159
|
-
|
159
|
+
Rails.logger.add(log_level, self.new_session_message)
|
160
160
|
self.build_task(task_data: session["#{self.id}::task_data"], session: session)
|
161
161
|
end
|
162
162
|
end
|
163
163
|
return self
|
164
164
|
rescue ZuoraConnect::Exceptions::HoldingPattern => ex
|
165
165
|
while self.marked_for_refresh?
|
166
|
-
|
166
|
+
Rails.logger.info("Holding - Expires in #{self.reset_mark_expires_at}. '#{self.new_session_message}'")
|
167
167
|
sleep(HOLDING_PATTERN_SLEEP)
|
168
168
|
end
|
169
169
|
self.reload_attributes([:refresh_token, :oauth_expires_at, :access_token])
|
@@ -171,7 +171,7 @@ module ZuoraConnect
|
|
171
171
|
retry
|
172
172
|
rescue => ex
|
173
173
|
if recoverable_session
|
174
|
-
|
174
|
+
Rails.logger.error("REBUILDING - Using backup expired cache")
|
175
175
|
self.build_task(task_data: session["#{self.id}::task_data"], session: session)
|
176
176
|
return self
|
177
177
|
else
|
@@ -181,12 +181,12 @@ module ZuoraConnect
|
|
181
181
|
begin
|
182
182
|
I18n.locale = self.locale
|
183
183
|
rescue I18n::InvalidLocale => ex
|
184
|
-
|
184
|
+
Rails.logger.debug("Invalid Locale: #{ex.message}")
|
185
185
|
end
|
186
186
|
Time.zone = self.timezone
|
187
187
|
tenants = self.task_data.dig('tenant_ids') || []
|
188
188
|
organizations = self.task_data.dig('organizations') || []
|
189
|
-
if defined?(ElasticAPM)
|
189
|
+
if defined?(ElasticAPM)
|
190
190
|
ElasticAPM.set_tag(:tenant_id, tenants.first)
|
191
191
|
ElasticAPM.set_tag(:organization, organizations.first)
|
192
192
|
end
|
@@ -200,33 +200,33 @@ module ZuoraConnect
|
|
200
200
|
response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
|
201
201
|
response_time = Time.now - start
|
202
202
|
|
203
|
-
|
203
|
+
Rails.logger.debug("[#{self.id}] REFRESH TASK - Connect Task Info Request Time #{response_time.round(2).to_s}")
|
204
204
|
if response.code == 200
|
205
205
|
self.build_task(task_data: JSON.parse(response.body), session: session)
|
206
206
|
self.last_refresh = Time.now.to_i
|
207
207
|
self.cache_app_instance
|
208
208
|
self.reset_mark_for_refresh
|
209
209
|
else
|
210
|
-
|
210
|
+
Rails.logger.fatal("[#{self.id}] REFRESH TASK - Failed Code #{response.code}")
|
211
211
|
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Communicating with Connect", response.body, response.code)
|
212
212
|
end
|
213
213
|
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS).concat(ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
214
214
|
if (refresh_count += 1) < 3
|
215
|
-
|
215
|
+
Rails.logger.info("[#{self.id}] REFRESH TASK - #{ex.class} Retrying(#{refresh_count})")
|
216
216
|
retry
|
217
217
|
else
|
218
|
-
|
218
|
+
Rails.logger.fatal("[#{self.id}] REFRESH TASK - #{ex.class} Failed #{refresh_count}x")
|
219
219
|
raise
|
220
220
|
end
|
221
221
|
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
222
222
|
if (refresh_count += 1) < 3
|
223
|
-
|
223
|
+
Rails.logger.info("[#{self.id}] REFRESH TASK - Failed Retrying(#{refresh_count})")
|
224
224
|
if ex.code == 401
|
225
225
|
self.refresh_oauth
|
226
226
|
end
|
227
227
|
retry
|
228
228
|
else
|
229
|
-
|
229
|
+
Rails.logger.fatal("[#{self.id}] REFRESH TASK - Failed #{refresh_count}x")
|
230
230
|
raise
|
231
231
|
end
|
232
232
|
end
|
@@ -316,8 +316,8 @@ module ZuoraConnect
|
|
316
316
|
end
|
317
317
|
end
|
318
318
|
rescue => ex
|
319
|
-
|
320
|
-
|
319
|
+
Rails.logger.error("Task Data: #{task_data}") if task_data.present?
|
320
|
+
Rails.logger.error("Task Session: #{session.to_h}") if session.present?
|
321
321
|
raise
|
322
322
|
end
|
323
323
|
|
@@ -393,7 +393,7 @@ module ZuoraConnect
|
|
393
393
|
def check_oauth_state(method)
|
394
394
|
#Refresh token if already expired
|
395
395
|
if self.oauth_expired?
|
396
|
-
|
396
|
+
Rails.logger.debug("[#{self.id}] Before '#{method}' method, Oauth expired")
|
397
397
|
self.refresh_oauth
|
398
398
|
end
|
399
399
|
end
|
@@ -412,7 +412,7 @@ module ZuoraConnect
|
|
412
412
|
}
|
413
413
|
response = HTTParty.post("#{ZuoraConnect.configuration.url}/oauth/token",:body => params)
|
414
414
|
response_time = Time.now - start
|
415
|
-
|
415
|
+
Rails.logger.info("[#{self.id}] REFRESH OAUTH - In #{response_time.round(2).to_s}")
|
416
416
|
|
417
417
|
if response.code == 200
|
418
418
|
response_body = JSON.parse(response.body)
|
@@ -422,15 +422,15 @@ module ZuoraConnect
|
|
422
422
|
self.oauth_expires_at = Time.at(response_body["created_at"].to_i) + response_body["expires_in"].seconds
|
423
423
|
self.save(:validate => false)
|
424
424
|
else
|
425
|
-
|
425
|
+
Rails.logger.fatal("[#{self.id}] REFRESH OAUTH - Failed Code #{response.code}")
|
426
426
|
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Refreshing Access Token", response.body, response.code)
|
427
427
|
end
|
428
428
|
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS).concat(ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
429
429
|
if (refresh_oauth_count += 1) < 3
|
430
|
-
|
430
|
+
Rails.logger.info("[#{self.id}] REFRESH OAUTH - #{ex.class} Retrying(#{refresh_oauth_count})")
|
431
431
|
retry
|
432
432
|
else
|
433
|
-
|
433
|
+
Rails.logger.fatal("[#{self.id}] REFRESH OAUTH - #{ex.class} Failed #{refresh_oauth_count}x")
|
434
434
|
raise
|
435
435
|
end
|
436
436
|
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
@@ -441,10 +441,10 @@ module ZuoraConnect
|
|
441
441
|
return if !self.oauth_expired?
|
442
442
|
|
443
443
|
if (refresh_oauth_count += 1) < 3
|
444
|
-
|
444
|
+
Rails.logger.info("[#{self.id}] REFRESH OAUTH - Failed Retrying(#{refresh_oauth_count})")
|
445
445
|
retry
|
446
446
|
else
|
447
|
-
|
447
|
+
Rails.logger.fatal("[#{self.id}] REFRESH OAUTH - Failed #{refresh_oauth_count}x")
|
448
448
|
raise
|
449
449
|
end
|
450
450
|
end
|
@@ -494,10 +494,10 @@ module ZuoraConnect
|
|
494
494
|
end
|
495
495
|
end
|
496
496
|
if cached_instance.blank?
|
497
|
-
|
497
|
+
Rails.logger.debug("[#{self.id}] Cached AppInstance Missing")
|
498
498
|
return session
|
499
499
|
else
|
500
|
-
|
500
|
+
Rails.logger.debug("[#{self.id}] Cached AppInstance Found")
|
501
501
|
return decrypt_data(data: cached_instance, rescue_return: session).merge(session)
|
502
502
|
end
|
503
503
|
else
|
@@ -509,7 +509,7 @@ module ZuoraConnect
|
|
509
509
|
if defined?(Redis.current)
|
510
510
|
#Task data must be present and the last refresh cannot be old. We dont want to overwite new cache data with old
|
511
511
|
if self.task_data.present? && (self.last_refresh.to_i > INSTANCE_REFRESH_WINDOW.ago.to_i)
|
512
|
-
|
512
|
+
Rails.logger.debug("[#{self.id}] Caching AppInstance")
|
513
513
|
Redis.current.setex("AppInstance:#{self.id}", INSTANCE_REDIS_CACHE_PERIOD.to_i, self.encrypt_data(data: self.save_data))
|
514
514
|
end
|
515
515
|
end
|
@@ -570,7 +570,7 @@ module ZuoraConnect
|
|
570
570
|
begin
|
571
571
|
return JSON.parse(encryptor.decrypt_and_verify(CGI::unescape(data)))
|
572
572
|
rescue ActiveSupport::MessageVerifier::InvalidSignature => ex
|
573
|
-
|
573
|
+
Rails.logger.add(Logger::FATAL, 'Error Decrypting') if log_fatal
|
574
574
|
return rescue_return
|
575
575
|
rescue JSON::ParserError => ex
|
576
576
|
return encryptor.decrypt_and_verify(CGI::unescape(data))
|
@@ -632,8 +632,8 @@ module ZuoraConnect
|
|
632
632
|
self.update_column(:catalog_update_attempt_at, Time.now.utc)
|
633
633
|
|
634
634
|
entity_reference = entity_id.blank? ? 'Default' : entity_id
|
635
|
-
|
636
|
-
|
635
|
+
Rails.logger.debug("Fetch Catalog")
|
636
|
+
Rails.logger.debug("Zuora Entity: #{entity_id.blank? ? 'default' : entity_id}")
|
637
637
|
|
638
638
|
login = zuora_login.client(entity_reference)
|
639
639
|
|
@@ -644,12 +644,12 @@ module ZuoraConnect
|
|
644
644
|
response = {'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{page_size}")}
|
645
645
|
while !response["nextPage"].blank?
|
646
646
|
url = login.rest_endpoint(response["nextPage"].split('/v1/').last)
|
647
|
-
|
647
|
+
Rails.logger.debug("Fetch Catalog URL #{url}")
|
648
648
|
output_json, response = login.rest_call(:debug => false, :url => url, :errors => [ZuoraAPI::Exceptions::ZuoraAPISessionError], :timeout_retry => true)
|
649
|
-
|
649
|
+
Rails.logger.debug("Fetch Catalog Response Code #{response.code}")
|
650
650
|
|
651
651
|
if !output_json['success'] =~ (/(true|t|yes|y|1)$/i) || output_json['success'].class != TrueClass
|
652
|
-
|
652
|
+
Rails.logger.error("Fetch Catalog DATA #{output_json.to_json}")
|
653
653
|
raise ZuoraAPI::Exceptions::ZuoraAPIError.new("Error Getting Catalog: #{output_json}")
|
654
654
|
end
|
655
655
|
|
@@ -939,9 +939,9 @@ module ZuoraConnect
|
|
939
939
|
|
940
940
|
def method_missing(method_sym, *arguments, &block)
|
941
941
|
if method_sym.to_s.include?("login")
|
942
|
-
|
943
|
-
|
944
|
-
|
942
|
+
Rails.logger.fatal("Method Missing #{method_sym}")
|
943
|
+
Rails.logger.fatal("Instance Data: #{self.task_data}")
|
944
|
+
Rails.logger.fatal("Instance Logins: #{self.logins}")
|
945
945
|
end
|
946
946
|
super
|
947
947
|
end
|
@@ -12,14 +12,14 @@ module ZuoraConnect
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def connect
|
15
|
-
|
15
|
+
Rails.logger.debug(self.format_metric_log('Telegraf','Need new connection')) if ZuoraConnect.configuration.telegraf_debug
|
16
16
|
uri = URI.parse(ZuoraConnect.configuration.telegraf_endpoint)
|
17
17
|
self.host = UDPSocket.new.tap do |socket|
|
18
18
|
socket.connect uri.host, uri.port
|
19
19
|
end
|
20
20
|
rescue => ex
|
21
21
|
self.host = nil
|
22
|
-
|
22
|
+
Rails.logger.warn(self.format_metric_log('Telegraf', "Failed to connect: #{ex.class}"))
|
23
23
|
end
|
24
24
|
|
25
25
|
def write(direction: 'Unknown', tags: {}, values: {})
|
@@ -44,9 +44,9 @@ module ZuoraConnect
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
if ZuoraConnect.configuration.telegraf_debug
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', tags.to_s))
|
48
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', values.to_s))
|
49
|
+
Rails.logger.debug(self.format_metric_log('Telegraf', "Writing '#{direction.capitalize}': #{time.real.round(5)} ms"))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -56,18 +56,14 @@ module ZuoraConnect
|
|
56
56
|
self.host.write InfluxDB::PointValue.new({series: series, tags: tags, values: values}).dump
|
57
57
|
rescue => ex
|
58
58
|
self.connect
|
59
|
-
|
59
|
+
Rails.logger.warn(self.format_metric_log('Telegraf',"Failed to write udp: #{ex.class}"))
|
60
60
|
end
|
61
61
|
|
62
62
|
def format_metric_log(message, dump = nil)
|
63
63
|
message_color, dump_color = "1;91", "0;1"
|
64
64
|
log_entry = " \e[#{message_color}m#{message}\e[0m "
|
65
65
|
log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump
|
66
|
-
|
67
|
-
log_entry
|
68
|
-
else
|
69
|
-
[message, dump].compact.join(' - ')
|
70
|
-
end
|
66
|
+
log_entry
|
71
67
|
end
|
72
68
|
|
73
69
|
def self.app_name
|
@@ -0,0 +1,25 @@
|
|
1
|
+
if defined?(ElasticAPM)
|
2
|
+
if ZuoraConnect.configuration.enable_apm && !defined?(Rails::Console)
|
3
|
+
ElasticAPM.agent.config.disable_send = false
|
4
|
+
else
|
5
|
+
ElasticAPM.agent.config.disable_send = true
|
6
|
+
end
|
7
|
+
case Rails.env.to_s
|
8
|
+
when 'production'
|
9
|
+
ElasticAPM.agent.config.server_url = "http://apm-server.logging:8200"
|
10
|
+
ElasticAPM.agent.config.transaction_sample_rate = 0.20
|
11
|
+
ElasticAPM.agent.config.capture_body = false
|
12
|
+
when 'staging'
|
13
|
+
ElasticAPM.agent.config.server_url = "http://apm-server.logging:8200"
|
14
|
+
ElasticAPM.agent.config.transaction_sample_rate = 1.0
|
15
|
+
when 'development'
|
16
|
+
ElasticAPM.agent.config.server_url = "http://logging.0.ecc.auw2.zuora:8200"
|
17
|
+
ElasticAPM.agent.config.transaction_sample_rate = 1.0
|
18
|
+
end
|
19
|
+
ElasticAPM.agent.config.pool_size = 1
|
20
|
+
ElasticAPM.agent.config.transaction_max_spans = 500
|
21
|
+
ElasticAPM.agent.config.ignore_url_patterns = ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*']
|
22
|
+
ElasticAPM.agent.config.verify_server_cert = false
|
23
|
+
ElasticAPM.agent.config.log_level = Logger::INFO
|
24
|
+
ElasticAPM.agent.config.service_name = ::ZuoraConnect::Telegraf.app_name
|
25
|
+
end
|
@@ -19,13 +19,4 @@ Resque.module_eval do
|
|
19
19
|
|
20
20
|
Hash[queue_names.zip(sizes)]
|
21
21
|
end
|
22
|
-
end
|
23
|
-
|
24
|
-
if defined?(Resque)
|
25
|
-
Resque.logger = ZuoraConnect.custom_logger(name: "Resque", type: 'Monologger')
|
26
|
-
Resque::Scheduler.logger = ZuoraConnect.custom_logger(name: "ResqueScheduler") if defined?(Resque::Scheduler)
|
27
|
-
end
|
28
|
-
|
29
|
-
Makara::Logging::Logger.logger = ZuoraConnect.custom_logger(name: "Makara") if defined?(Makara)
|
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", type: 'Monologger') if defined?(ActionMailer)
|
22
|
+
end
|
@@ -2,8 +2,7 @@ if defined?(Unicorn::WorkerKiller)
|
|
2
2
|
Unicorn::WorkerKiller.module_eval do
|
3
3
|
self.singleton_class.send(:alias_method, :kill_self_old, :kill_self)
|
4
4
|
def self.kill_self(logger, start_time)
|
5
|
-
|
6
|
-
self.kill_self_old(@unicorn_logger, start_time)
|
5
|
+
self.kill_self_old(logger, start_time)
|
7
6
|
ZuoraConnect::AppInstance.write_to_telegraf(direction: 'Unicorn-Killer', tags: {app_instance: 0}, values: {kill: 1})
|
8
7
|
end
|
9
8
|
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
|
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
|
@@ -212,7 +212,7 @@ if defined?(Rails)
|
|
212
212
|
if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
|
213
213
|
# Rails3
|
214
214
|
ActiveSupport.on_load(:after_initialize) do
|
215
|
-
HttpLogger.logger =
|
215
|
+
HttpLogger.logger = Rails.logger unless HttpLogger.logger
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
@@ -7,7 +7,28 @@ module Resque
|
|
7
7
|
module Plugins
|
8
8
|
module CustomLogger
|
9
9
|
def before_perform(*args)
|
10
|
-
|
10
|
+
marker = SecureRandom.uuid
|
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
|
+
Resque.logger = logger
|
31
|
+
Rails.logger = logger
|
11
32
|
case args.class.to_s
|
12
33
|
when "Array"
|
13
34
|
if args.first.class == Hash
|
@@ -18,10 +39,8 @@ module Resque
|
|
18
39
|
when "Hash"
|
19
40
|
data = args.merge({:worker_class => self.to_s})
|
20
41
|
end
|
21
|
-
data
|
22
|
-
data.merge!({:app_instance_id => data.dig(:job, 'app_instance_id')}) if data.dig(:job, 'app_instance_id').present?
|
23
|
-
Rails.logger.info(data) if data.present?
|
42
|
+
Rails.logger.info(data.to_json) if data.present?
|
24
43
|
end
|
25
44
|
end
|
26
45
|
end
|
27
|
-
end
|
46
|
+
end
|
data/lib/zuora_connect.rb
CHANGED
@@ -9,77 +9,13 @@ 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'
|
13
12
|
require 'metrics/influx/point_value'
|
14
13
|
require 'metrics/net'
|
15
14
|
|
16
15
|
module ZuoraConnect
|
17
16
|
class << self
|
18
17
|
attr_accessor :configuration
|
19
|
-
attr_writer :logger
|
20
|
-
|
21
|
-
def logger
|
22
|
-
case Rails.env.to_s
|
23
|
-
when 'development'
|
24
|
-
Rails.logger
|
25
|
-
else
|
26
|
-
@logger ||= custom_logger(name: "Connect", level: Rails.logger.level)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
require 'ougai'
|
30
|
-
|
31
|
-
|
32
|
-
def custom_logger(name: "", level: Rails.logger.present? ? Rails.logger.level : MonoLogger::INFO, type: :ougai)
|
33
|
-
#puts name + ' - ' + {Logger::WARN => 'Logger::WARN', Logger::ERROR => 'Logger::ERROR', Logger::DEBUG => 'Logger::DEBUG', Logger::INFO => 'Logger::INFO' }[level] + ' - '
|
34
|
-
if type == :ougai
|
35
|
-
require 'ougai'
|
36
|
-
#logger = Ougai::Logger.new(MonoLogger.new(STDOUT))
|
37
|
-
logger = Ougai::Logger.new(STDOUT)
|
38
|
-
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
|
39
|
-
logger.level = level
|
40
|
-
logger.before_log = lambda do |data|
|
41
|
-
data[:trace_id] = ZuoraConnect::RequestIdMiddleware.request_id if ZuoraConnect::RequestIdMiddleware.request_id.present?
|
42
|
-
if Thread.current[:appinstance].present?
|
43
|
-
data[:app_instance_id] = Thread.current[:appinstance].id
|
44
|
-
logitems = Thread.current[:appinstance].logitems
|
45
|
-
if logitems.present? && logitems.class == Hash
|
46
|
-
data[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
|
47
|
-
data[:organization] = logitems[:organization] if logitems[:organization].present?
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
else
|
52
|
-
logger = MonoLogger.new(STDOUT)
|
53
|
-
logger.level = level
|
54
|
-
logger.formatter = proc do |serverity, datetime, progname, msg|
|
55
|
-
begin
|
56
|
-
msg = JSON.parse(msg)
|
57
|
-
rescue JSON::ParserError => ex
|
58
|
-
end
|
59
|
-
|
60
|
-
require 'json'
|
61
|
-
store = {
|
62
|
-
name: name,
|
63
|
-
level: serverity,
|
64
|
-
timestamp: datetime.strftime('%FT%T.%6NZ'),
|
65
|
-
pid: Process.pid,
|
66
|
-
message: name == "ActionMailer" ? msg.strip : msg
|
67
|
-
}
|
68
|
-
if Thread.current[:appinstance].present?
|
69
|
-
store[:app_instance_id] = Thread.current[:appinstance].id
|
70
|
-
logitems = Thread.current[:appinstance].logitems
|
71
|
-
if logitems.present? && logitems.class == Hash
|
72
|
-
store[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
|
73
|
-
store[:organization] = logitems[:organization] if logitems[:organization].present?
|
74
|
-
end
|
75
|
-
end
|
76
|
-
JSON.dump(store) + "\n"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
return logger
|
80
|
-
end
|
81
18
|
end
|
82
|
-
|
83
19
|
module Controllers
|
84
20
|
autoload :Helpers, 'zuora_connect/controllers/helpers'
|
85
21
|
end
|
@@ -103,44 +39,4 @@ module ZuoraConnect
|
|
103
39
|
|
104
40
|
return configuration
|
105
41
|
end
|
106
|
-
|
107
|
-
def self.elastic_apm_defaults
|
108
|
-
defaults = {}
|
109
|
-
case Rails.env.to_s
|
110
|
-
when 'production'
|
111
|
-
defaults = {
|
112
|
-
server_url: "http://apm-server.logging:8200",
|
113
|
-
transaction_sample_rate: 0.20,
|
114
|
-
capture_body: 'errors'
|
115
|
-
}
|
116
|
-
when 'staging'
|
117
|
-
defaults = {
|
118
|
-
server_url: "http://apm-server.logging:8200",
|
119
|
-
transaction_sample_rate: 1.0
|
120
|
-
}
|
121
|
-
when 'development'
|
122
|
-
defaults = {
|
123
|
-
server_url: "http://logging.0.ecc.auw2.zuora:8200",
|
124
|
-
transaction_sample_rate: 1.0
|
125
|
-
}
|
126
|
-
when 'test'
|
127
|
-
defaults = {
|
128
|
-
active: false,
|
129
|
-
disable_send: true
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
defaults.merge!({
|
134
|
-
pool_size: 1,
|
135
|
-
transaction_max_spans: 500,
|
136
|
-
ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
|
137
|
-
verify_server_cert: false,
|
138
|
-
log_level: Logger::INFO,
|
139
|
-
service_name: ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : Rails.application.class.parent_name,
|
140
|
-
logger: ZuoraConnect.custom_logger(name: "ElasticAPM", level: MonoLogger::WARN)
|
141
|
-
})
|
142
|
-
defaults.merge!({disable_send: true}) if defined?(Rails::Console)
|
143
|
-
|
144
|
-
return defaults
|
145
|
-
end
|
146
42
|
end
|
@@ -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, :silencer_resque_finish, :blpop_queue
|
6
|
+
attr_accessor :enable_metrics, :enable_apm, :telegraf_endpoint, :telegraf_debug, :custom_prometheus_update_block, :silencer_resque_finish, :blpop_queue
|
7
7
|
|
8
8
|
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
|
9
9
|
|
@@ -24,6 +24,7 @@ module ZuoraConnect
|
|
24
24
|
@enable_metrics = false
|
25
25
|
@telegraf_endpoint = 'udp://telegraf-app-metrics.monitoring.svc.cluster.local:8094'
|
26
26
|
@telegraf_debug = false
|
27
|
+
@enable_apm = false
|
27
28
|
# OAuth Settings
|
28
29
|
@oauth_client_id = ""
|
29
30
|
@oauth_client_secret = ""
|
@@ -8,23 +8,23 @@ module ZuoraConnect
|
|
8
8
|
#Skip session for api requests
|
9
9
|
Thread.current[:appinstance] = nil
|
10
10
|
request.session_options[:skip] = true
|
11
|
-
ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM)
|
11
|
+
ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM)
|
12
12
|
|
13
13
|
start_time = Time.now
|
14
14
|
if request.headers["API-Token"].present?
|
15
15
|
@appinstance = ZuoraConnect::AppInstance.where(:api_token => request.headers["API-Token"]).first
|
16
|
-
|
16
|
+
Rails.logger.debug("[#{@appinstance.id}] API REQUEST - API token") if @appinstance.present?
|
17
17
|
check_instance
|
18
18
|
else
|
19
19
|
authenticate_or_request_with_http_basic do |username, password|
|
20
20
|
@appinstance = ZuoraConnect::AppInstance.where(:token => password).first
|
21
21
|
@appinstance ||= ZuoraConnect::AppInstance.where(:api_token => password).first
|
22
|
-
|
22
|
+
Rails.logger.debug("[#{@appinstance.id}] API REQUEST - Basic Auth") if @appinstance.present?
|
23
23
|
check_instance
|
24
24
|
end
|
25
25
|
end
|
26
26
|
if @appinstance.present?
|
27
|
-
|
27
|
+
Rails.logger.debug("[#{@appinstance.id}] Authenticate App API Request Completed In - #{(Time.now - start_time).round(2)}s")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -66,13 +66,13 @@ module ZuoraConnect
|
|
66
66
|
render "zuora_connect/static/invalid_launch_request"
|
67
67
|
end
|
68
68
|
rescue => ex
|
69
|
-
|
69
|
+
Rails.logger.debug("Error parsing Instance ID's: #{ex.message}")
|
70
70
|
render "zuora_connect/static/invalid_launch_request"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
def authenticate_connect_app_request
|
75
|
-
ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM)
|
75
|
+
ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM)
|
76
76
|
Thread.current[:appinstance] = nil
|
77
77
|
if params[:app_instance_ids].present? && !params[:app_instance_id].present?
|
78
78
|
begin
|
@@ -86,7 +86,7 @@ module ZuoraConnect
|
|
86
86
|
@appinstance.cache_app_instance
|
87
87
|
session["appInstance"] = app_instance_ids[0]
|
88
88
|
else
|
89
|
-
|
89
|
+
Rails.logger.fatal("Launch Error: Param Instance didnt match session data")
|
90
90
|
render "zuora_connect/static/invalid_launch_request"
|
91
91
|
return
|
92
92
|
end
|
@@ -95,7 +95,7 @@ module ZuoraConnect
|
|
95
95
|
return
|
96
96
|
end
|
97
97
|
rescue => ex
|
98
|
-
|
98
|
+
Rails.logger.fatal("Launch Error: #{ex.message}")
|
99
99
|
render "zuora_connect/static/invalid_launch_request"
|
100
100
|
return
|
101
101
|
end
|
@@ -113,7 +113,7 @@ module ZuoraConnect
|
|
113
113
|
return
|
114
114
|
end
|
115
115
|
rescue => ex
|
116
|
-
|
116
|
+
Rails.logger.fatal("Launch Error: #{ex.message}")
|
117
117
|
render "zuora_connect/static/invalid_launch_request"
|
118
118
|
return
|
119
119
|
end
|
@@ -136,16 +136,16 @@ module ZuoraConnect
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
if session["#{@appinstance.id}::user::email"].present?
|
139
|
-
ElasticAPM.set_user(session["#{@appinstance.id}::user::email"]) if defined?(ElasticAPM)
|
139
|
+
ElasticAPM.set_user(session["#{@appinstance.id}::user::email"]) if defined?(ElasticAPM)
|
140
140
|
PaperTrail.whodunnit = session["#{@appinstance.id}::user::email"] if defined?(PaperTrail)
|
141
141
|
end
|
142
142
|
begin
|
143
143
|
I18n.locale = session["#{@appinstance.id}::user::locale"] ? session["#{@appinstance.id}::user::locale"] : @appinstance.locale
|
144
144
|
rescue I18n::InvalidLocale => ex
|
145
|
-
|
145
|
+
Rails.logger.error("Invalid Locale: #{ex.message}")
|
146
146
|
end
|
147
147
|
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
148
|
-
|
148
|
+
Rails.logger.debug("[#{@appinstance.blank? ? "N/A" : @appinstance.id}] Authenticate App Request Completed In - #{(Time.now - start_time).round(2)}s")
|
149
149
|
end
|
150
150
|
|
151
151
|
def persist_connect_app_session
|
@@ -170,6 +170,7 @@ module ZuoraConnect
|
|
170
170
|
def setup_instance_via_data
|
171
171
|
session.clear
|
172
172
|
values = JSON.parse(ZuoraConnect::AppInstance.decrypt_response(Base64.urlsafe_decode64(request["data"])))
|
173
|
+
Rails.logger.debug("Data: #{values.to_json}")
|
173
174
|
if values["param_data"]
|
174
175
|
values["param_data"].each do |k ,v|
|
175
176
|
params[k] = v
|
@@ -184,7 +185,7 @@ module ZuoraConnect
|
|
184
185
|
session["#{values["appInstance"]}::user::email"] = values["current_user"]["email"]
|
185
186
|
end
|
186
187
|
|
187
|
-
|
188
|
+
Rails.logger.debug("App Params: #{values.to_json}}") if Rails.env != "production"
|
188
189
|
|
189
190
|
@appinstance = ZuoraConnect::AppInstance.where(:id => values["appInstance"].to_i).first
|
190
191
|
if @appinstance.blank?
|
@@ -192,7 +193,7 @@ module ZuoraConnect
|
|
192
193
|
begin
|
193
194
|
Apartment::Tenant.create(values["appInstance"].to_s)
|
194
195
|
rescue Apartment::TenantExists => ex
|
195
|
-
|
196
|
+
Rails.logger.debug("Tenant Already Exists")
|
196
197
|
end
|
197
198
|
@appinstance = ZuoraConnect::AppInstance.new(:api_token => values[:api_token],:id => values["appInstance"].to_i, :access_token => values["access_token"].blank? ? values["user"] : values["access_token"], :token => values["refresh_token"] , :refresh_token => values["refresh_token"].blank? ? values["key"] : values["refresh_token"], :oauth_expires_at => values["expires"])
|
198
199
|
@appinstance.save(:validate => false)
|
@@ -249,7 +250,7 @@ module ZuoraConnect
|
|
249
250
|
end
|
250
251
|
Thread.current[:appinstance] = @appinstance
|
251
252
|
PaperTrail.whodunnit = "API User" if defined?(PaperTrail)
|
252
|
-
ElasticAPM.set_user("API User") if defined?(ElasticAPM)
|
253
|
+
ElasticAPM.set_user("API User") if defined?(ElasticAPM)
|
253
254
|
return true
|
254
255
|
else
|
255
256
|
render text: "Access Denied", status: :unauthorized
|
data/lib/zuora_connect/engine.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'middleware/metrics_middleware'
|
2
|
-
require 'middleware/request_id_middleware'
|
3
2
|
|
4
3
|
module ZuoraConnect
|
5
4
|
class Railtie < Rails::Railtie
|
@@ -23,38 +22,33 @@ module ZuoraConnect
|
|
23
22
|
end
|
24
23
|
end
|
25
24
|
initializer "zuora_connect.configure_rails_initialization" do |app|
|
26
|
-
app.middleware.insert_after Rack::Sendfile,
|
27
|
-
app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
|
25
|
+
app.middleware.insert_after Rack::Sendfile, Middleware::MetricsMiddleware
|
28
26
|
end
|
29
27
|
|
30
28
|
# hook to process_action
|
31
|
-
ActiveSupport::Notifications.subscribe('process_action.action_controller',
|
29
|
+
ActiveSupport::Notifications.subscribe('process_action.action_controller', Middleware::PageRequest.new)
|
32
30
|
|
33
31
|
initializer(:rails_stdout_logging, before: :initialize_logger) do
|
34
32
|
if Rails.env != 'development' && !ENV['DEIS_APP'].blank?
|
35
33
|
require 'lograge'
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
35
|
+
logger.formatter = ::Logger::Formatter.new
|
36
|
+
# logger.formatter = proc do |severity, datetime, progname, msg|
|
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]
|
39
41
|
Rails.configuration.lograge.enabled = true
|
40
|
-
Rails.configuration.
|
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: 'Rails Request', request: data }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
#Rails.configuration.lograge.formatter = Lograge::Formatters::Json.new
|
42
|
+
Rails.configuration.lograge.formatter = Lograge::Formatters::Json.new
|
49
43
|
Rails.configuration.lograge.custom_options = lambda do |event|
|
50
44
|
exceptions = %w(controller action format id)
|
51
45
|
items = {
|
52
46
|
#time: event.time.strftime('%FT%T.%6N'),
|
53
|
-
params: event.payload[:params].except(*exceptions)
|
47
|
+
params: event.payload[:params].except(*exceptions),
|
48
|
+
exception: event.payload[:exception],
|
49
|
+
exception_object: event.payload[:exception_object],
|
50
|
+
process_id: Process.pid
|
54
51
|
}
|
55
|
-
items.merge!({exception_object: event.payload[:exception_object]}) if event.payload[:exception_object].present?
|
56
|
-
items.merge!({exception: event.payload[:exception]}) if event.payload[:exception].present?
|
57
|
-
|
58
52
|
if Thread.current[:appinstance].present?
|
59
53
|
items.merge!({appinstance_id: Thread.current[:appinstance].id, connect_user: Thread.current[:appinstance].connect_user, new_session: Thread.current[:appinstance].new_session_message})
|
60
54
|
if Thread.current[:appinstance].logitems.present? && Thread.current[:appinstance].logitems.class == Hash
|
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.81
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -25,59 +25,59 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: zuora_api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.21
|
31
34
|
- - ">="
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
36
|
+
version: 1.6.21
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.21
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 1.6.21
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: httparty
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.6.21
|
48
51
|
- - "~>"
|
49
52
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
53
|
+
version: 0.16.4
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.16.4
|
51
57
|
type: :runtime
|
52
58
|
prerelease: false
|
53
59
|
version_requirements: !ruby/object:Gem::Requirement
|
54
60
|
requirements:
|
55
|
-
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 1.6.21
|
58
61
|
- - "~>"
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
63
|
+
version: 0.16.4
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.16.4
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
68
|
+
name: elastic-apm
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
64
70
|
requirements:
|
65
71
|
- - ">="
|
66
72
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0
|
68
|
-
- - "~>"
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 0.16.4
|
73
|
+
version: '0'
|
71
74
|
type: :runtime
|
72
75
|
prerelease: false
|
73
76
|
version_requirements: !ruby/object:Gem::Requirement
|
74
77
|
requirements:
|
75
78
|
- - ">="
|
76
79
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 0.16.4
|
80
|
+
version: '0'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: bundler
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,6 +299,7 @@ files:
|
|
299
299
|
- app/views/zuora_connect/static/session_error.html.erb
|
300
300
|
- config/initializers/apartment.rb
|
301
301
|
- config/initializers/aws.rb
|
302
|
+
- config/initializers/elastic_apm.rb
|
302
303
|
- config/initializers/object_method_hooks.rb
|
303
304
|
- config/initializers/postgresql_adapter.rb
|
304
305
|
- config/initializers/prometheus.rb
|
@@ -318,11 +319,9 @@ files:
|
|
318
319
|
- db/migrate/20110503003604_catalog_default.rb
|
319
320
|
- db/migrate/20180301052853_add_catalog_attempted_at.rb
|
320
321
|
- db/migrate/20181206162339_add_fields_to_instance.rb
|
321
|
-
- lib/logging/connect_formatter.rb
|
322
322
|
- lib/metrics/influx/point_value.rb
|
323
323
|
- lib/metrics/net.rb
|
324
324
|
- lib/middleware/metrics_middleware.rb
|
325
|
-
- lib/middleware/request_id_middleware.rb
|
326
325
|
- lib/resque/additions.rb
|
327
326
|
- lib/resque/dynamic_queues.rb
|
328
327
|
- lib/resque/plugins/custom_logger.rb
|
@@ -392,11 +391,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
392
391
|
version: '0'
|
393
392
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
394
393
|
requirements:
|
395
|
-
- - "
|
394
|
+
- - ">="
|
396
395
|
- !ruby/object:Gem::Version
|
397
|
-
version:
|
396
|
+
version: '0'
|
398
397
|
requirements: []
|
399
|
-
|
398
|
+
rubyforge_project:
|
399
|
+
rubygems_version: 2.6.8
|
400
400
|
signing_key:
|
401
401
|
specification_version: 4
|
402
402
|
summary: Summary of Connect.
|
@@ -1,39 +0,0 @@
|
|
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
|