zuora_connect 1.5.40j → 1.5.40k

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: bcf3f3b3e395fbab36024b040ed49831c2a2389a
4
- data.tar.gz: aed0261f4b1f289597512b342a1b236860d894b3
3
+ metadata.gz: 1ab8265f0d808ba6afe86de40005431b22c63025
4
+ data.tar.gz: 7ee4bdf9c8d4a4a2025abbfed0fb832dfb19507f
5
5
  SHA512:
6
- metadata.gz: 1aa850d37b10d9a69f713cdc3b16ccc4e221355afd7e3104a0ea7e2a2ea78dcc616fee26cc3a2ccc0e7875634b3f046f045fab8410b961a326b71a770900f05f
7
- data.tar.gz: a43af30791a2a7f967ba90526f51a1fdf38d0a8774700025cbf44358b0a43e0e99fa8f0d2be7850132fb61ad10cabbfbbfe7192534e2dd6ea893f619a826b41b
6
+ metadata.gz: a5767173c008b7ccabd534dd58dec659cb54456bcc6e2c05763fa0c43e4f10cc9056b4e2fc1dd44a201d4baae89062a981accf1e365f361556a129cf4b2aa4f5
7
+ data.tar.gz: 47fe75a6e62d7172d2f98ffec025d089d03950f6883005e8881d3678fa54592d6c0888284b9d36754072e80d0f4377bffb4b044b1ee5e1af25ed7787e9da871f
@@ -1,4 +1,5 @@
1
1
  module ZuoraConnect
2
+ require "uri"
2
3
  class AppInstanceBase < ActiveRecord::Base
3
4
  default_scope {select(ZuoraConnect::AppInstance.column_names.delete_if {|x| ["catalog_mapping", "catalog"].include?(x) }) }
4
5
  after_initialize :init
@@ -73,8 +74,8 @@ module ZuoraConnect
73
74
  if error_type
74
75
  begin
75
76
  ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_outbound,
76
- tags: {endpoint: endpoint_name, status: status_code, process_type: p_type, "app_instance": app_instance, "function_name": function_name, method: method_name},
77
- values: {response_time: response_time, "error_type": error_type})
77
+ tags: {endpoint: endpoint_name, status: status_code, process_type: p_type, "app_instance": app_instance, "function_name": function_name, method: method_name, "error_type": error_type},
78
+ values: {response_time: response_time})
78
79
  rescue => e
79
80
  raise e
80
81
  end
@@ -183,7 +184,7 @@ module ZuoraConnect
183
184
 
184
185
  def refresh(session = nil)
185
186
  refresh_count ||= 0
186
-
187
+ error_type = ""
187
188
  start = Time.now
188
189
  response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
189
190
  response_time = Time.now - start
@@ -203,6 +204,7 @@ module ZuoraConnect
203
204
  Rails.logger.info("[#{self.id}] REFRESH TASK - #{ex.class} Retrying(#{refresh_count})")
204
205
  retry
205
206
  else
207
+ error_type = "#{ex.class}"
206
208
  Rails.logger.fatal("[#{self.id}] REFRESH TASK - #{ex.class} Failed #{refresh_count}x")
207
209
  raise
208
210
  end
@@ -214,9 +216,16 @@ module ZuoraConnect
214
216
  end
215
217
  retry
216
218
  else
219
+ error_type = "#{ex.class}"
217
220
  Rails.logger.fatal("[#{self.id}] REFRESH TASK - Failed #{refresh_count}x")
218
221
  raise
219
222
  end
223
+ ensure
224
+ # Writing to telegraf
225
+ status_code = response.code if response
226
+ endpoint_name = URI(ZuoraConnect.configuration.url).host
227
+ Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
228
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("response_time": response_time, "status_code": status_code, "endpoint_name": endpoint_name, "direction": "outbound", "error_type": error_type, "function_name": "#{self.class}##{__method__}", "method_name": "GET", "app_instance": app_instance)
220
229
  end
221
230
 
222
231
  #### START Task Mathods ####
@@ -256,13 +265,28 @@ module ZuoraConnect
256
265
  end
257
266
 
258
267
  def updateOption(optionId, value)
259
- return HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/application_options/#{optionId}/edit?value=#{value}",:body => {:access_token => self.username})
268
+ begin
269
+ start_time = Time.now
270
+ response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/application_options/#{optionId}/edit?value=#{value}",:body => {:access_token => self.username})
271
+ rescue => e
272
+ error_type = "#{e.class}"
273
+ ensure
274
+ end_time = Time.now
275
+ response_time = end_time - start_time
276
+ status_code = response.code if response
277
+ endpoint_name = URI(ZuoraConnect.configuration.url).host
278
+ Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
279
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("response_time": response_time, "status_code": status_code, "endpoint_name": endpoint_name, "direction": "outbound", "error_type": error_type, "function_name": "#{self.class}##{__method__}", "method_name": "GET", "app_instance": app_instance)
280
+ return response
281
+ end
260
282
  end
261
283
 
262
284
  #This can update an existing login, add a new login, change to another existing login
263
285
  #EXAMPLE: {"name": "ftp_login_14","username": "ftplogin7","tenant_type": "Custom","password": "test2","url": "www.ftp.com","custom_data": { "path": "/var/usr/test"}}
264
286
  def update_logins(options)
265
287
  update_login_count ||= 0
288
+ start_time = Time.now
289
+ error_type = ""
266
290
  response = HTTParty.post(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}/logins",:body => {:access_token => self.username}.merge(options))
267
291
  parsed_json = JSON.parse(response.body)
268
292
  if response.code == 200
@@ -277,10 +301,11 @@ module ZuoraConnect
277
301
  else
278
302
  raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error Communicating with Connect", response.body, response.code)
279
303
  end
280
- rescue Net::ReadTimeout, Net::OpenTimeout, Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNREFUSED, SocketError
304
+ rescue Net::ReadTimeout, Net::OpenTimeout, Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNREFUSED, SocketError => ex
281
305
  if (update_login_count += 1) < 3
282
306
  retry
283
307
  else
308
+ error_type = "#{ex.class}"
284
309
  raise
285
310
  end
286
311
  rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
@@ -290,8 +315,16 @@ module ZuoraConnect
290
315
  end
291
316
  retry
292
317
  else
318
+ error_type = "#{ex.class}"
293
319
  raise
294
320
  end
321
+ ensure
322
+ end_time = Time.now
323
+ response_time = end_time - start_time
324
+ status_code = response.code if response
325
+ endpoint_name = URI(ZuoraConnect.configuration.url).host
326
+ Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
327
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("response_time": response_time, "status_code": status_code, "endpoint_name": endpoint_name, "direction": "outbound", "error_type": error_type, "function_name": "#{self.class}##{__method__}", "method_name": "POST", "app_instance": app_instance)
295
328
  end
296
329
  #### END Task Mathods ####
297
330
 
@@ -310,7 +343,7 @@ module ZuoraConnect
310
343
 
311
344
  def refresh_oauth
312
345
  refresh_oauth_count ||= 0
313
-
346
+ error_type = ""
314
347
  start = Time.now
315
348
  params = {
316
349
  :grant_type => "refresh_token",
@@ -337,6 +370,7 @@ module ZuoraConnect
337
370
  Rails.logger.info("[#{self.id}] REFRESH OAUTH - #{ex.class} Retrying(#{refresh_oauth_count})")
338
371
  retry
339
372
  else
373
+ error_type = "#{ex.class}"
340
374
  Rails.logger.fatal("[#{self.id}] REFRESH OAUTH - #{ex.class} Failed #{refresh_oauth_count}x")
341
375
  raise
342
376
  end
@@ -351,9 +385,15 @@ module ZuoraConnect
351
385
  Rails.logger.info("[#{self.id}] REFRESH OAUTH - Failed Retrying(#{refresh_oauth_count})")
352
386
  retry
353
387
  else
388
+ error_type = "#{ex.class}"
354
389
  Rails.logger.fatal("[#{self.id}] REFRESH OAUTH - Failed #{refresh_oauth_count}x")
355
390
  raise
356
391
  end
392
+ ensure
393
+ status_code = response.code if response
394
+ endpoint_name = URI(ZuoraConnect.configuration.url).host
395
+ Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
396
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("response_time": response_time, "status_code": status_code, "endpoint_name": endpoint_name, "direction": "outbound", "error_type": error_type, "function_name": "#{self.class}##{__method__}", "method_name": "POST", "app_instance": app_instance)
357
397
  end
358
398
  #### END Connect OAUTH methods ####
359
399
 
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.5.40j"
2
+ VERSION = "1.5.40k"
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.5.40j
4
+ version: 1.5.40k
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-08-02 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment