zuora_connect 1.5.40k → 1.5.40m

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ab8265f0d808ba6afe86de40005431b22c63025
4
- data.tar.gz: 7ee4bdf9c8d4a4a2025abbfed0fb832dfb19507f
3
+ metadata.gz: f531eec6fa72b6f9651a6961a64eda3cd0ce741f
4
+ data.tar.gz: 0eb620aa24830ce66a9572856a01dc6fd637daf9
5
5
  SHA512:
6
- metadata.gz: a5767173c008b7ccabd534dd58dec659cb54456bcc6e2c05763fa0c43e4f10cc9056b4e2fc1dd44a201d4baae89062a981accf1e365f361556a129cf4b2aa4f5
7
- data.tar.gz: 47fe75a6e62d7172d2f98ffec025d089d03950f6883005e8881d3678fa54592d6c0888284b9d36754072e80d0f4377bffb4b044b1ee5e1af25ed7787e9da871f
6
+ metadata.gz: 8c0d4e8e12a915fc5fd5f2da1b24d1edb0cc7376422733a871072b4c4df03112b51f0bb7714cec20b61ac52b5a886de5bbd8dd5b48d3718d3e7543c06f2c1cb6
7
+ data.tar.gz: dbf20a23eacd142c6d91e764f7e3af84389269ee3ee3ebcc9caf2b309e9d08e3753a5893628bcb05ef59895a48c35943b6d4f6e6cc9d8220024a6d3028d01ba0
@@ -39,6 +39,10 @@ module ZuoraConnect
39
39
  return p_type
40
40
  end
41
41
 
42
+ # payloads with 500 requests do not have status as it is not set by the controller
43
+ # https://github.com/rails/rails/issues/33335
44
+ status_code = payload[:status] ? payload[:status] : payload[:exception_object].present? ? 500 : ""
45
+
42
46
  # Write to telegraf
43
47
  def self.write_to_telegraf(endpoint_name: nil, method_name: nil, status_code: nil, response_time: nil, db_runtime: nil, view_runtime: nil, content_type: nil, direction: nil, error_type: nil, app_instance: nil, function_name: nil)
44
48
 
@@ -4,26 +4,30 @@ module Middleware
4
4
  # Object of this class is passed to the ActiveSupport::Notification hook
5
5
  class PageRequest
6
6
 
7
- # This method is triggered when a non error page is loaded (not 404, 500)
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 payload[:status]
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
11
15
 
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
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
17
21
 
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
22
+ status_code = payload[:status] ? payload[:status] : ""
23
+
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 = 500 if payload[:exception_object].present?
27
+
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")
23
30
 
24
- # Write to telegraf
25
- ZuoraConnect::AppInstanceBase.write_to_telegraf("endpoint_name": request_path, "method_name": payload[:method], "status_code": payload[:status], "response_time": response_time, "db_runtime": payload[:db_runtime].to_f, "view_runtime": payload[:view_runtime], "content_type": content_type, "direction": "inbound")
26
- end
27
31
  end
28
32
  end
29
33
 
@@ -82,18 +86,21 @@ module Middleware
82
86
  end
83
87
 
84
88
  # Writing to telegraf: Handle 404 and 500 requests
85
- if @status != 200
89
+ if @status == 404 || @status == 304
86
90
  # Getting the endpoint and content_type
87
- if @status == 404
88
- request_path = "ActionController#RoutingError"
89
- elsif env["action_controller.instance"].present?
90
- request_path = "#{env["action_controller.instance"].controller_path}##{env["action_controller.instance"].action_name}"
91
- else
92
- # Handling requests which do not have controllers
93
- request_path = "#{env['SCRIPT_NAME'][1..-1]}#UnknownAction" if env["SCRIPT_NAME"].present?
94
- end
91
+ request_path = @status == 404 ? "ActionController#RoutingError" : env["action_controller.instance"].present? ? "#{env["action_controller.instance"].class}##{env["action_controller.instance"].action_name}" : ""
92
+
93
+ # Uncomment following block of code for handling engine requests/requests without controller
94
+ # else
95
+ # # Handling requests which do not have controllers (engines)
96
+ # if env["SCRIPT_NAME"].present?
97
+ # controller_path = "#{env['SCRIPT_NAME'][1..-1]}"
98
+ # controller_path = controller_path.sub("/", "::")
99
+ # request_path = "#{controller_path}#UnknownAction"
100
+ # end
101
+
95
102
  content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
96
- 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")
103
+ 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?
97
104
  end
98
105
 
99
106
  [@status, @headers, @response]
@@ -31,8 +31,6 @@ module ZuoraConnect
31
31
  # hook to process_action
32
32
  ActiveSupport::Notifications.subscribe('process_action.action_controller', Middleware::PageRequest.new)
33
33
 
34
-
35
-
36
34
  end
37
35
 
38
36
 
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.5.40k"
2
+ VERSION = "1.5.40m"
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.40k
4
+ version: 1.5.40m
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-03 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment