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: 649c8327936482f8991749977b8fa36676dbd925
4
- data.tar.gz: 0117a671f3900066277087216002858aa496858a
3
+ metadata.gz: 8148ad4722e2a30204f306ef657aa2de3c82cb7c
4
+ data.tar.gz: f7788d5db43ff6e3b1e3cff4f5418ddd0f15936f
5
5
  SHA512:
6
- metadata.gz: 3214ceecbe556e62f6ecf4eb6b8818dcd86bbee74a2c3294240ec4d47363bc26787c1ab3214c348421d84afe3d3083fb1cc9d995274de1ec904a5f3ed00cbe1e
7
- data.tar.gz: fefff57791fa3b60f958258e78f021839efd5f78d6855ac9c413659f7f8b27ee9b23138bc358ffbdeef8d95f490342003dd25d682915e4fce83ef511bdaac986
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
- # Getting the process type
46
- p_type = ZuoraConnect::AppInstanceBase.get_process_type
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
- if direction == "inbound"
49
- Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
50
+ if direction == "inbound"
51
+ Thread.current[:appinstance].present? ? app_instance = Thread.current[:appinstance].id : app_instance = 0
50
52
 
51
- # Separately handling 200 and non 200 as influx does not accept nil as a value
52
- if db_runtime && view_runtime
53
- # 200 requests
54
- begin
55
- ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
56
- tags: {"controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
57
- values: {response_time: response_time, db_time: db_runtime, view_time: view_runtime})
58
- rescue => e
59
- raise e
60
- end
61
- else
62
- # non 200 requests
63
- begin
64
- ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_inbound,
65
- tags: {"controller_action": endpoint_name, "content-type": content_type, method: method_name, status: status_code, process_type: p_type, "app_instance": app_instance},
66
- values: {response_time: response_time})
67
- rescue=> e
68
- raise e
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
- elsif direction == "outbound"
73
- # if there is an error
74
- if error_type
75
- begin
76
- ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_outbound,
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})
79
- rescue => e
80
- raise e
81
- end
82
- else
83
- begin
84
- ZuoraConnect.configuration.telegraf_client.write(ZuoraConnect.configuration.app_name_outbound,
85
- tags: {endpoint: endpoint_name, status: status_code, process_type: p_type, "app_instance": app_instance, "function_name": function_name, method: method_name},
86
- values: {response_time: response_time})
87
- rescue => e
88
- raise e
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, :app_name_inbound, :app_name_outbound
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
- @app_name_inbound = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}-inbound" : "#{Rails.application.class.parent_name}-inbound"
20
- @app_name_outbound = ENV['DEIS_APP'].present? ? "#{ENV['DEIS_APP']}-outbound" : "#{Rails.application.class.parent_name}-outbound"
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 = ""
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.5.40q"
2
+ VERSION = "1.5.40r"
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.40q
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-08 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment