zuora_connect 1.5.40g → 1.5.40h
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: e9439f50b9f6588bd3341a2dde7ac8ba84c915dd
|
|
4
|
+
data.tar.gz: 2d332bf487246078326b224b6bd075e42b9a8389
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b050de51628e1b3e578fc0f31aa9b6c1a480e93f06906215206704f20d904a98cd94e8e269cab80c039ff56eac89c47ec2ac871a990facdfa9cc0573da6792a8
|
|
7
|
+
data.tar.gz: 5fd54ca7d3df430feaa4e9c578f9e756fd4a72689f0ef67566c7c99450cb4d3af8da90b5ec58ef3e345bae2385b9692c50e200d038766e39e163e019460b66bd
|
|
@@ -25,19 +25,70 @@ module ZuoraConnect
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
#
|
|
28
|
+
# Methods for writing Telegraf metrics
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
# Returns the process type if any
|
|
31
|
+
def self.get_process_type
|
|
32
|
+
p_type = nil
|
|
33
|
+
if ENV['HOSTNAME']
|
|
34
|
+
temp = ENV['HOSTNAME'].split(ENV['DEIS_APP'])[1]
|
|
35
|
+
temp = temp.split(/(-[0-9a-zA-Z]{5})$/)[0] # remove the 5 char hash
|
|
36
|
+
p_type = temp[1, temp.rindex("-")-1]
|
|
37
|
+
end
|
|
38
|
+
return p_type
|
|
39
|
+
end
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
# Write to telegraf
|
|
42
|
+
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)
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
# Getting the process type
|
|
45
|
+
p_type = ZuoraConnect::AppInstanceBase.get_process_type
|
|
46
|
+
|
|
47
|
+
if direction == "inbound"
|
|
48
|
+
Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
|
|
39
49
|
|
|
50
|
+
# Separately handling 200 and non 200 as influx does not accept nil as a value
|
|
51
|
+
if db_runtime && view_runtime
|
|
52
|
+
# 200 requests
|
|
53
|
+
begin
|
|
54
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
|
|
55
|
+
tags: {"controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
|
|
56
|
+
values: {response_time: response_time, db_time: db_runtime, view_time: view_runtime})
|
|
57
|
+
rescue => e
|
|
58
|
+
raise e
|
|
59
|
+
end
|
|
60
|
+
else
|
|
61
|
+
# non 200 requests
|
|
62
|
+
begin
|
|
63
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
|
|
64
|
+
tags: {"controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
|
|
65
|
+
values: {response_time: response_time})
|
|
66
|
+
rescue=> e
|
|
67
|
+
raise e
|
|
68
|
+
end
|
|
69
|
+
end
|
|
40
70
|
|
|
71
|
+
elsif direction == "outbound"
|
|
72
|
+
# if there is an error
|
|
73
|
+
if error_type
|
|
74
|
+
begin
|
|
75
|
+
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})
|
|
78
|
+
rescue => e
|
|
79
|
+
raise e
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
begin
|
|
83
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_outbound,
|
|
84
|
+
tags: {endpoint: endpoint_name, status: status_code, process_type: p_type, "app_instance": app_instance, "function_name": function_name, method: method_name},
|
|
85
|
+
values: {response_time: response_time})
|
|
86
|
+
rescue => e
|
|
87
|
+
raise e
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
41
92
|
|
|
42
93
|
def apartment_switch(method = nil, migrate = false)
|
|
43
94
|
begin
|
|
@@ -1,67 +1,29 @@
|
|
|
1
1
|
module Middleware
|
|
2
2
|
require 'uri'
|
|
3
3
|
|
|
4
|
-
# Returns the process type if any
|
|
5
|
-
def self.get_process_type
|
|
6
|
-
p_type = nil
|
|
7
|
-
if ENV['HOSTNAME']
|
|
8
|
-
temp = ENV['HOSTNAME'].split(ENV['DEIS_APP'])[1]
|
|
9
|
-
temp = temp.split(/(-[0-9a-zA-Z]{5})$/)[0] # remove the 5 char hash
|
|
10
|
-
p_type = temp[1, temp.rindex("-")-1]
|
|
11
|
-
end
|
|
12
|
-
return p_type
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Write to telegraf
|
|
17
|
-
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)
|
|
18
|
-
|
|
19
|
-
# Getting the process type
|
|
20
|
-
p_type = Middleware::get_process_type
|
|
21
|
-
|
|
22
|
-
# Separately handling 200 and non 200 as influx does not accept nil as a value
|
|
23
|
-
if db_runtime && view_runtime
|
|
24
|
-
# 200 requests
|
|
25
|
-
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
|
|
26
|
-
tags: {endpoint: endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type},
|
|
27
|
-
values: {response_time: response_time, db_time: db_runtime, view_time: view_runtime})
|
|
28
|
-
else
|
|
29
|
-
# non 200 requests
|
|
30
|
-
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
|
|
31
|
-
tags: {endpoint: endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type},
|
|
32
|
-
values: {response_time: response_time})
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
4
|
# Object of this class is passed to the ActiveSupport::Notification hook
|
|
39
5
|
class PageRequest
|
|
40
6
|
|
|
41
7
|
# This method is triggered when a non error page is loaded (not 404, 500)
|
|
42
8
|
def call(name, started, finished, unique_id, payload)
|
|
43
9
|
|
|
44
|
-
|
|
45
|
-
block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
|
|
46
|
-
if block_words.any? { |word| payload[:path].include?(word) }
|
|
47
|
-
return nil
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Getting the endpoint and the content_type
|
|
51
|
-
content_hash = {:html => "text/html", :js => "application/javascript", :json => "application/json"}
|
|
52
|
-
content_type = content_hash[payload[:format]]
|
|
10
|
+
if payload[:status]
|
|
53
11
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
response_time = finished-started
|
|
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
|
|
61
17
|
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
64
23
|
|
|
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
|
|
65
27
|
end
|
|
66
28
|
end
|
|
67
29
|
|
|
@@ -79,6 +41,7 @@ module Middleware
|
|
|
79
41
|
def call(env)
|
|
80
42
|
start_time = Time.now
|
|
81
43
|
@status, @headers, @response = @app.call(env)
|
|
44
|
+
end_time = Time.now
|
|
82
45
|
|
|
83
46
|
# If the url contains any CSS or JavaScript files then do not collect metrics for them
|
|
84
47
|
block_words = ["css", "assets", "jpg", "png", "jpeg", "ico"]
|
|
@@ -86,7 +49,7 @@ module Middleware
|
|
|
86
49
|
return [@status, @headers, @response]
|
|
87
50
|
end
|
|
88
51
|
|
|
89
|
-
|
|
52
|
+
|
|
90
53
|
response_time = end_time - start_time
|
|
91
54
|
|
|
92
55
|
#Prometheus Stuff
|
|
@@ -121,9 +84,16 @@ module Middleware
|
|
|
121
84
|
# Writing to telegraf: Handle 404 and 500 requests
|
|
122
85
|
if @status != 200
|
|
123
86
|
# Getting the endpoint and content_type
|
|
124
|
-
|
|
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
|
|
125
95
|
content_type = @headers['Content-Type'].split(';')[0] if @headers['Content-Type']
|
|
126
|
-
|
|
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")
|
|
127
97
|
end
|
|
128
98
|
|
|
129
99
|
[@status, @headers, @response]
|
|
@@ -6,11 +6,6 @@ module ZuoraConnect
|
|
|
6
6
|
module Helpers
|
|
7
7
|
extend ActiveSupport::Concern
|
|
8
8
|
|
|
9
|
-
# Method to write outbound metrics to telegraf
|
|
10
|
-
def write_morse(msg)
|
|
11
|
-
puts "msg:",msg
|
|
12
|
-
end
|
|
13
|
-
|
|
14
9
|
def authenticate_app_api_request
|
|
15
10
|
#Skip session for api requests
|
|
16
11
|
Thread.current[:appinstance] = nil
|
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.
|
|
4
|
+
version: 1.5.40h
|
|
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-
|
|
11
|
+
date: 2018-08-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: apartment
|
|
@@ -354,49 +354,49 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
354
354
|
version: 1.3.1
|
|
355
355
|
requirements: []
|
|
356
356
|
rubyforge_project:
|
|
357
|
-
rubygems_version: 2.6.
|
|
357
|
+
rubygems_version: 2.6.8
|
|
358
358
|
signing_key:
|
|
359
359
|
specification_version: 4
|
|
360
360
|
summary: Summary of Connect.
|
|
361
361
|
test_files:
|
|
362
362
|
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
|
363
|
-
- test/dummy/app/assets/javascripts/application.js
|
|
364
|
-
- test/dummy/app/assets/stylesheets/application.css
|
|
365
|
-
- test/dummy/app/controllers/application_controller.rb
|
|
366
|
-
- test/dummy/app/helpers/application_helper.rb
|
|
367
|
-
- test/dummy/app/views/layouts/application.html.erb
|
|
368
|
-
- test/dummy/bin/bundle
|
|
369
|
-
- test/dummy/bin/rails
|
|
370
363
|
- test/dummy/bin/rake
|
|
364
|
+
- test/dummy/bin/bundle
|
|
371
365
|
- test/dummy/bin/setup
|
|
372
|
-
- test/dummy/
|
|
373
|
-
- test/dummy/
|
|
374
|
-
- test/dummy/
|
|
366
|
+
- test/dummy/bin/rails
|
|
367
|
+
- test/dummy/Rakefile
|
|
368
|
+
- test/dummy/public/favicon.ico
|
|
369
|
+
- test/dummy/public/404.html
|
|
370
|
+
- test/dummy/public/422.html
|
|
371
|
+
- test/dummy/public/500.html
|
|
372
|
+
- test/dummy/app/controllers/application_controller.rb
|
|
373
|
+
- test/dummy/app/views/layouts/application.html.erb
|
|
374
|
+
- test/dummy/app/helpers/application_helper.rb
|
|
375
|
+
- test/dummy/app/assets/javascripts/application.js
|
|
376
|
+
- test/dummy/app/assets/stylesheets/application.css
|
|
377
|
+
- test/dummy/README.rdoc
|
|
378
|
+
- test/dummy/config.ru
|
|
379
|
+
- test/dummy/config/locales/en.yml
|
|
380
|
+
- test/dummy/config/routes.rb
|
|
375
381
|
- test/dummy/config/environment.rb
|
|
376
|
-
- test/dummy/config/
|
|
382
|
+
- test/dummy/config/database.yml
|
|
383
|
+
- test/dummy/config/secrets.yml
|
|
384
|
+
- test/dummy/config/boot.rb
|
|
377
385
|
- test/dummy/config/environments/production.rb
|
|
386
|
+
- test/dummy/config/environments/development.rb
|
|
378
387
|
- test/dummy/config/environments/test.rb
|
|
379
|
-
- test/dummy/config/initializers/assets.rb
|
|
380
388
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
381
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
|
382
389
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
|
390
|
+
- test/dummy/config/initializers/assets.rb
|
|
383
391
|
- test/dummy/config/initializers/inflections.rb
|
|
384
|
-
- test/dummy/config/initializers/mime_types.rb
|
|
385
392
|
- test/dummy/config/initializers/session_store.rb
|
|
386
393
|
- test/dummy/config/initializers/wrap_parameters.rb
|
|
387
|
-
- test/dummy/config/
|
|
388
|
-
- test/dummy/config/
|
|
389
|
-
- test/dummy/config/
|
|
390
|
-
- test/
|
|
391
|
-
- test/
|
|
392
|
-
- test/dummy/public/422.html
|
|
393
|
-
- test/dummy/public/500.html
|
|
394
|
-
- test/dummy/public/favicon.ico
|
|
395
|
-
- test/dummy/Rakefile
|
|
396
|
-
- test/dummy/README.rdoc
|
|
394
|
+
- test/dummy/config/initializers/mime_types.rb
|
|
395
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
|
396
|
+
- test/dummy/config/application.rb
|
|
397
|
+
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|
|
398
|
+
- test/test_helper.rb
|
|
397
399
|
- test/fixtures/zuora_connect/app_instances.yml
|
|
398
400
|
- test/integration/navigation_test.rb
|
|
399
|
-
- test/lib/generators/zuora_connect/datatable_generator_test.rb
|
|
400
401
|
- test/models/zuora_connect/app_instance_test.rb
|
|
401
|
-
- test/test_helper.rb
|
|
402
402
|
- test/zuora_connect_test.rb
|