zuora_connect 1.6.02 → 1.6.03

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: 17316c51abd303f8dfb74d3cb46b576cd68d9112
4
- data.tar.gz: cdb87171dbd831bf2a22f922000d2ab50b2e8bce
3
+ metadata.gz: c59ae0f28e122082e3d0ac9ca8165e78ae8a6ae7
4
+ data.tar.gz: 801cd0f2b3d59f950885e7c57e89d226692b09e0
5
5
  SHA512:
6
- metadata.gz: 9c170e401deb9d28cc824451e261d9530a46eb72e9bb363ed921fd37464d9b06e6e9f128770c9719e2734d0bcf2e07e56f5d4ea982ea6e4e0ab7dae30ec819b7
7
- data.tar.gz: a57c73106bfbe5d57d722e5fd5a602fbef5bc06d230e661ff08ad082b1214d15c98f6770f0e42d09072e1e1b2c6f3f9144e55e221680853ddcc087e687e01f94
6
+ metadata.gz: 1cd4d6f64f4770a3f46eac1567350397d5138a531190bb85e2fa9c9f9df46d75432aaae7c642821e21f38a20f6cd01d950829c2c4ca8db04b0aee817ed68079c
7
+ data.tar.gz: 324c2d3570ef46dc3ae9613af2b4056771e561179c501b37d9b1d53ffc24ce5626b01eaac556883820d8c041894954032cc8838d4cac81d7fcd9e2264525d5cb
@@ -47,7 +47,7 @@ module ZuoraConnect
47
47
  # Getting the process type
48
48
  p_type = ZuoraConnect::AppInstanceBase.get_process_type
49
49
 
50
- if direction == "inbound" && ZuoraConnect::Configuration.new.enable_inbound_metrics_flag
50
+ if direction == "inbound" && ZuoraConnect.configuration.enable_inbound_metrics_flag
51
51
  Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
52
52
 
53
53
  # Separately handling 200 and non 200 as influx does not accept nil as a value
@@ -71,7 +71,7 @@ module ZuoraConnect
71
71
  end
72
72
  end
73
73
 
74
- elsif direction == "outbound" && ZuoraConnect::Configuration.new.enable_outbound_metrics_flag
74
+ elsif direction == "outbound" && ZuoraConnect.configuration.enable_outbound_metrics_flag
75
75
  # if there is an error
76
76
  if error_type
77
77
  begin
@@ -7,25 +7,28 @@ module Middleware
7
7
  # This method is triggered when a non error page is loaded (not 404)
8
8
  def call(name, started, finished, unique_id, payload)
9
9
 
10
- # If the url contains any css or JavaScript files then do not collect metrics for them
11
- block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
12
- if block_words.any? { |word| payload[:path].include?(word) }
13
- return nil
14
- end
10
+ if ZuoraConnect.configuration.enable_inbound_metrics_flag == true
11
+
12
+ # If the url contains any css or JavaScript files then do not collect metrics for them
13
+ block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
14
+ if block_words.any? { |word| payload[:path].include?(word) }
15
+ return nil
16
+ end
15
17
 
16
- # Getting the endpoint and the content_type
17
- content_hash = {:html => "text/html", :js => "application/javascript", :json => "application/json"}
18
- content_hash.key?(payload[:format]) ? content_type = content_hash[payload[:format]] : content_type = payload[:format]
19
- request_path = "#{payload[:controller]}##{payload[:action]}"
20
- response_time = finished-started
18
+ # Getting the endpoint and the content_type
19
+ content_hash = {:html => "text/html", :js => "application/javascript", :json => "application/json"}
20
+ content_hash.key?(payload[:format]) ? content_type = content_hash[payload[:format]] : content_type = payload[:format]
21
+ request_path = "#{payload[:controller]}##{payload[:action]}"
22
+ response_time = finished-started
21
23
 
22
- # payloads with 500 requests do not have status as it is not set by the controller
23
- # https://github.com/rails/rails/issues/33335
24
- status_code = payload[:status] ? payload[:status] : payload[:exception_object].present? ? 500 : ""
24
+ # payloads with 500 requests do not have status as it is not set by the controller
25
+ # https://github.com/rails/rails/issues/33335
26
+ status_code = payload[:status] ? payload[:status] : payload[:exception_object].present? ? 500 : ""
25
27
 
26
- # Write to telegraf
27
- ZuoraConnect::AppInstanceBase.write_to_telegraf("endpoint_name": request_path, "method_name": payload[:method], "status_code": status_code, "response_time": response_time, "db_runtime": payload[:db_runtime].to_f, "view_runtime": payload[:view_runtime], "content_type": content_type, "direction": "inbound")
28
+ # Write to telegraf
29
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("endpoint_name": request_path, "method_name": payload[:method], "status_code": status_code, "response_time": response_time, "db_runtime": payload[:db_runtime].to_f, "view_runtime": payload[:view_runtime], "content_type": content_type, "direction": "inbound")
28
30
 
31
+ end
29
32
  end
30
33
  end
31
34
 
@@ -44,64 +47,63 @@ module Middleware
44
47
  start_time = Time.now
45
48
  @status, @headers, @response = @app.call(env)
46
49
  end_time = Time.now
50
+ if ZuoraConnect.configuration.enable_inbound_metrics_flag == true
51
+ # If the url contains any CSS or JavaScript files then do not collect metrics for them
52
+ block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
53
+ if block_words.any? { |word| env['PATH_INFO'].include?(word) }
54
+ return [@status, @headers, @response]
55
+ end
47
56
 
48
- # If the url contains any CSS or JavaScript files then do not collect metrics for them
49
- block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
50
- if block_words.any? { |word| env['PATH_INFO'].include?(word) }
51
- return [@status, @headers, @response]
52
- end
53
-
57
+ response_time = end_time - start_time
54
58
 
55
- response_time = end_time - start_time
59
+ if defined? Prometheus
60
+ #Prometheus Stuff
61
+ if env['PATH_INFO'] == '/connect/internal/metrics'
56
62
 
57
- if defined? Prometheus
58
- #Prometheus Stuff
59
- if env['PATH_INFO'] == '/connect/internal/metrics'
63
+ #Do something before each scrape
64
+ if defined? Resque.redis
60
65
 
61
- #Do something before each scrape
62
- if defined? Resque.redis
66
+ app_name = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}" : "#{Rails.application.class.parent_name}"
67
+ begin
63
68
 
64
- app_name = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}" : "#{Rails.application.class.parent_name}"
65
- begin
69
+ Resque.redis.ping
66
70
 
67
- Resque.redis.ping
71
+ Prometheus::REDIS_CONNECTION.set({connection:'redis',name:app_name},1)
72
+ Prometheus::FINISHED_JOBS.set({type:'resque',name:app_name},Resque.info[:processed])
73
+ Prometheus::PENDING_JOBS.set({type:'resque',name:app_name},Resque.info[:pending])
74
+ Prometheus::ACTIVE_WORKERS.set({type:'resque',name:app_name},Resque.info[:working])
75
+ Prometheus::WORKERS.set({type:'resque',name:app_name},Resque.info[:workers])
76
+ Prometheus::FAILED_JOBS.set({type:'resque',name:app_name},Resque.info[:failed])
68
77
 
69
- Prometheus::REDIS_CONNECTION.set({connection:'redis',name:app_name},1)
70
- Prometheus::FINISHED_JOBS.set({type:'resque',name:app_name},Resque.info[:processed])
71
- Prometheus::PENDING_JOBS.set({type:'resque',name:app_name},Resque.info[:pending])
72
- Prometheus::ACTIVE_WORKERS.set({type:'resque',name:app_name},Resque.info[:working])
73
- Prometheus::WORKERS.set({type:'resque',name:app_name},Resque.info[:workers])
74
- Prometheus::FAILED_JOBS.set({type:'resque',name:app_name},Resque.info[:failed])
78
+ rescue Redis::CannotConnectError
79
+ Prometheus::REDIS_CONNECTION.set({connection:'redis',name:app_name},0)
80
+ end
75
81
 
76
- rescue Redis::CannotConnectError
77
- Prometheus::REDIS_CONNECTION.set({connection:'redis',name:app_name},0)
82
+ if ZuoraConnect.configuration.custom_prometheus_update_block != nil
83
+ ZuoraConnect.configuration.custom_prometheus_update_block.call()
84
+ end
78
85
  end
79
86
 
80
- if ZuoraConnect.configuration.custom_prometheus_update_block != nil
81
- ZuoraConnect.configuration.custom_prometheus_update_block.call()
82
- end
83
87
  end
84
-
88
+ end
89
+ # Writing to telegraf: Handle 404 and 500 requests
90
+ if @status == 404 || @status == 304
91
+ # Getting the endpoint and content_type
92
+ request_path = @status == 404 ? "ActionController#RoutingError" : env["action_controller.instance"].present? ? "#{env["action_controller.instance"].class}##{env["action_controller.instance"].action_name}" : ""
93
+
94
+ # Uncomment following block of code for handling engine requests/requests without controller
95
+ # else
96
+ # # Handling requests which do not have controllers (engines)
97
+ # if env["SCRIPT_NAME"].present?
98
+ # controller_path = "#{env['SCRIPT_NAME'][1..-1]}"
99
+ # controller_path = controller_path.sub("/", "::")
100
+ # request_path = "#{controller_path}#UnknownAction"
101
+ # end
102
+
103
+ content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
104
+ ZuoraConnect::AppInstanceBase.write_to_telegraf("endpoint_name": request_path, "method_name": env['REQUEST_METHOD'], "status_code": @status, "response_time": response_time, "content_type": content_type, "direction": "inbound") if request_path.present?
85
105
  end
86
106
  end
87
- # Writing to telegraf: Handle 404 and 500 requests
88
- if @status == 404 || @status == 304
89
- # Getting the endpoint and content_type
90
- request_path = @status == 404 ? "ActionController#RoutingError" : env["action_controller.instance"].present? ? "#{env["action_controller.instance"].class}##{env["action_controller.instance"].action_name}" : ""
91
-
92
- # Uncomment following block of code for handling engine requests/requests without controller
93
- # else
94
- # # Handling requests which do not have controllers (engines)
95
- # if env["SCRIPT_NAME"].present?
96
- # controller_path = "#{env['SCRIPT_NAME'][1..-1]}"
97
- # controller_path = controller_path.sub("/", "::")
98
- # request_path = "#{controller_path}#UnknownAction"
99
- # end
100
-
101
- content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
102
- ZuoraConnect::AppInstanceBase.write_to_telegraf("endpoint_name": request_path, "method_name": env['REQUEST_METHOD'], "status_code": @status, "response_time": response_time, "content_type": content_type, "direction": "inbound") if request_path.present?
103
- end
104
-
105
107
  [@status, @headers, @response]
106
108
 
107
109
  end
@@ -16,23 +16,17 @@ module ZuoraConnect
16
16
  ::Rails.configuration.action_dispatch.x_sendfile_header = nil
17
17
  end
18
18
 
19
- # Base object not being loaded at this point for some reason
20
- if ZuoraConnect::Configuration.new.enable_inbound_metrics_flag == true
21
-
22
- if defined? Prometheus
23
- initializer "prometheus.configure_rails_initialization" do |app|
24
- app.middleware.use Prometheus::Middleware::Exporter,(options ={:path => '/connect/internal/metrics'})
25
- end
26
- end
27
- initializer "zuora_connect.configure_rails_initialization" do |app|
28
- app.middleware.insert_after Rack::Sendfile, Middleware::MetricsMiddleware
19
+ if defined? Prometheus
20
+ initializer "prometheus.configure_rails_initialization" do |app|
21
+ app.middleware.use Prometheus::Middleware::Exporter,(options ={:path => '/connect/internal/metrics'})
29
22
  end
30
-
31
- # hook to process_action
32
- ActiveSupport::Notifications.subscribe('process_action.action_controller', Middleware::PageRequest.new)
33
-
23
+ end
24
+ initializer "zuora_connect.configure_rails_initialization" do |app|
25
+ app.middleware.insert_after Rack::Sendfile, Middleware::MetricsMiddleware
34
26
  end
35
27
 
28
+ # hook to process_action
29
+ ActiveSupport::Notifications.subscribe('process_action.action_controller', Middleware::PageRequest.new)
36
30
 
37
31
  initializer(:rails_stdout_logging, before: :initialize_logger) do
38
32
  if Rails.env != 'development' && !ENV['DEIS_APP'].blank?
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.6.02"
2
+ VERSION = "1.6.03"
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.6.02
4
+ version: 1.6.03
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-14 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment