zuora_connect 1.5.40q → 1.5.40r
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: 8148ad4722e2a30204f306ef657aa2de3c82cb7c
|
|
4
|
+
data.tar.gz: f7788d5db43ff6e3b1e3cff4f5418ddd0f15936f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a9ea5dbb1e243d5848c9f9ce87ddcc1f7c48ba0d33c94412f1374e507d3fcc4f2ef298cb6ad470863a9ddd04175ec11b3ecbdc8bdaa0611a1ebd52353e7bb69
|
|
7
|
+
data.tar.gz: 1283d1f7df48be8cb88a58cb4c1e18c838626fb364f527be547ebd5eda9440bc3543a649f941f716ab12e556e1bbdc5010840bc4d9386307061551dfe735b045
|
|
@@ -2,7 +2,7 @@ module ZuoraConnect
|
|
|
2
2
|
class StaticController < ApplicationController
|
|
3
3
|
before_filter :authenticate_connect_app_request, :except => [:health, :session_error, :invalid_app_instance_error]
|
|
4
4
|
after_filter :persist_connect_app_session, :except => [:health, :session_error, :invalid_app_instance_error]
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
def session_error
|
|
7
7
|
respond_to do |format|
|
|
8
8
|
format.html
|
|
@@ -17,6 +17,11 @@ module ZuoraConnect
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
def metrics
|
|
21
|
+
type = params[:type].present? ? params[:type] : "versions"
|
|
22
|
+
render json: ZuoraConnect::AppInstanceBase.get_metrics(type), status: 200
|
|
23
|
+
end
|
|
24
|
+
|
|
20
25
|
def health
|
|
21
26
|
render json: {
|
|
22
27
|
message: "Alive",
|
|
@@ -42,55 +42,92 @@ module ZuoraConnect
|
|
|
42
42
|
# Write to telegraf
|
|
43
43
|
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
44
|
|
|
45
|
-
#
|
|
46
|
-
|
|
45
|
+
# To avoid writing metrics from rspec tests
|
|
46
|
+
if ENV['DEIS_APP']
|
|
47
|
+
# Getting the process type
|
|
48
|
+
p_type = ZuoraConnect::AppInstanceBase.get_process_type
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
if direction == "inbound"
|
|
51
|
+
Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
# Separately handling 200 and non 200 as influx does not accept nil as a value
|
|
54
|
+
if db_runtime && view_runtime
|
|
55
|
+
# 200 requests
|
|
56
|
+
begin
|
|
57
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.influxdb_series_name_inbound,
|
|
58
|
+
tags: {"app_name": "#{ZuoraConnect.configuration.app_name}", "controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
|
|
59
|
+
values: {response_time: response_time, db_time: db_runtime, view_time: view_runtime})
|
|
60
|
+
rescue => e
|
|
61
|
+
raise e
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
# non 200 requests
|
|
65
|
+
begin
|
|
66
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.influxdb_series_name_inbound,
|
|
67
|
+
tags: {"app_name": "#{ZuoraConnect.configuration.app_name}", "controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
|
|
68
|
+
values: {response_time: response_time})
|
|
69
|
+
rescue=> e
|
|
70
|
+
raise e
|
|
71
|
+
end
|
|
69
72
|
end
|
|
70
|
-
end
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
elsif direction == "outbound"
|
|
75
|
+
# if there is an error
|
|
76
|
+
if error_type
|
|
77
|
+
begin
|
|
78
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.influxdb_series_name_outbound,
|
|
79
|
+
tags: {"app_name": "#{ZuoraConnect.configuration.app_name}", 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},
|
|
80
|
+
values: {response_time: response_time})
|
|
81
|
+
rescue => e
|
|
82
|
+
raise e
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
begin
|
|
86
|
+
ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.influxdb_series_name_outbound,
|
|
87
|
+
tags: {"app_name": "#{ZuoraConnect.configuration.app_name}", endpoint: endpoint_name, status: status_code, process_type: p_type, "app_instance": app_instance, "function_name": function_name, method: method_name},
|
|
88
|
+
values: {response_time: response_time})
|
|
89
|
+
rescue => e
|
|
90
|
+
raise e
|
|
91
|
+
end
|
|
89
92
|
end
|
|
90
93
|
end
|
|
91
94
|
end
|
|
92
95
|
end
|
|
93
96
|
|
|
97
|
+
def self.get_metrics(type)
|
|
98
|
+
namespace = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}" : "#{Rails.application.class.parent_name}"
|
|
99
|
+
|
|
100
|
+
data = {}
|
|
101
|
+
|
|
102
|
+
if type == "versions"
|
|
103
|
+
data = {
|
|
104
|
+
Namespace: namespace,
|
|
105
|
+
Version_Gem: ZuoraConnect::VERSION,
|
|
106
|
+
Version_Zuora: ZuoraAPI::VERSION ,
|
|
107
|
+
Version_Ruby: RUBY_VERSION,
|
|
108
|
+
Version_Rails: Rails.version,
|
|
109
|
+
hold: 1
|
|
110
|
+
}
|
|
111
|
+
elsif type == "stats"
|
|
112
|
+
begin
|
|
113
|
+
Resque.redis.ping
|
|
114
|
+
data = {
|
|
115
|
+
Namespace: namespace,
|
|
116
|
+
Resque:{
|
|
117
|
+
Jobs_Finished: Resque.info[:processed] ,
|
|
118
|
+
Jobs_Failed: Resque.info[:failed],
|
|
119
|
+
Jobs_Pending: Resque.info[:pending],
|
|
120
|
+
Workers_Active: Resque.info[:working],
|
|
121
|
+
Workers_Total: Resque.info[:workers]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
rescue
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
return data.to_json
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
|
|
94
131
|
def apartment_switch(method = nil, migrate = false)
|
|
95
132
|
begin
|
|
96
133
|
Apartment::Tenant.switch!(self.id) if self.persisted?
|
data/config/routes.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
ZuoraConnect::Engine.routes.draw do
|
|
2
2
|
get '/health' => 'static#health'
|
|
3
|
+
get '/internal/data' => 'static#metrics'
|
|
3
4
|
get '/invalid_session' => 'static#session_error', :as => :invalid_session
|
|
4
5
|
get '/invalid_instance' => "static#invalid_app_instance_error", :as => :invalid_instance
|
|
5
6
|
namespace :api do
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module ZuoraConnect
|
|
2
2
|
class Configuration
|
|
3
|
-
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri,:use_s3, :default_locale,:dev_mode_appinstance ,:dev_mode_admin, :dev_mode_user, :dev_mode_pass, :default_time_zone,:delayed_job,:url, :private_key, :dev_mode_logins,:dev_mode_mode, :dev_mode_options, :mode, :timeout,:dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :additional_apartment_models, :telegraf_endpoint, :enable_metrics_flag, :telegraf_client, :custom_prometheus_update_block, :
|
|
3
|
+
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri,:use_s3, :default_locale,:dev_mode_appinstance ,:dev_mode_admin, :dev_mode_user, :dev_mode_pass, :default_time_zone,:delayed_job,:url, :private_key, :dev_mode_logins,:dev_mode_mode, :dev_mode_options, :mode, :timeout,:dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :additional_apartment_models, :telegraf_endpoint, :enable_metrics_flag, :telegraf_client, :custom_prometheus_update_block, :app_name, :influxdb_series_name_inbound, :influxdb_series_name_outbound
|
|
4
4
|
|
|
5
5
|
def initialize
|
|
6
6
|
@default_locale = :en
|
|
@@ -16,8 +16,9 @@ module ZuoraConnect
|
|
|
16
16
|
@telegraf_client = Telegraf::Agent.new @telegraf_endpoint
|
|
17
17
|
|
|
18
18
|
# Setting the app name for telegraf write
|
|
19
|
-
@
|
|
20
|
-
@
|
|
19
|
+
@app_name = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}" : "#{Rails.application.class.parent_name}"
|
|
20
|
+
@influxdb_series_name_inbound = "request-inbound"
|
|
21
|
+
@influxdb_series_name_outbound = "request-outbound"
|
|
21
22
|
|
|
22
23
|
# OAuth Settings
|
|
23
24
|
@oauth_client_id = ""
|
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.40r
|
|
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-
|
|
11
|
+
date: 2018-08-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: apartment
|