Module: ZuoraConnect
- Defined in:
- lib/zuora_connect.rb,
lib/zuora_connect/engine.rb,
lib/zuora_connect/railtie.rb,
lib/zuora_connect/version.rb,
lib/zuora_connect/exceptions.rb,
app/models/zuora_connect/login.rb,
lib/zuora_connect/configuration.rb,
lib/zuora_connect/views/helpers.rb,
app/models/zuora_connect/telegraf.rb,
lib/middleware/metrics_middleware.rb,
lib/middleware/request_id_middleware.rb,
app/models/zuora_connect/app_instance.rb,
lib/zuora_connect/controllers/helpers.rb,
app/models/zuora_connect/app_instance_base.rb,
app/helpers/zuora_connect/application_helper.rb,
app/controllers/zuora_connect/static_controller.rb,
app/controllers/zuora_connect/application_controller.rb,
app/helpers/zuora_connect/api/v1/app_instance_helper.rb,
app/controllers/zuora_connect/admin/tenant_controller.rb,
app/controllers/zuora_connect/api/v1/app_instance_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, Controllers, Exceptions, Views
Classes: AppInstance, AppInstanceBase, ApplicationController, Configuration, Engine, Login, MetricsMiddleware, PageRequest, Railtie, RequestIdMiddleware, StaticController, Telegraf
Constant Summary
collapse
- VERSION =
"2.0.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
18
19
20
|
# File 'lib/zuora_connect.rb', line 18
def configuration
@configuration
end
|
.logger ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/zuora_connect.rb', line 21
def logger
case Rails.env.to_s
when 'development'
Rails.logger
else
@logger ||= custom_logger(name: "Connect", level: Rails.logger.level)
end
end
|
Class Method Details
103
104
105
106
107
108
109
|
# File 'lib/zuora_connect.rb', line 103
def self.configure
yield(configuration)
::Apartment.excluded_models << "Delayed::Job" if configuration.delayed_job
::Apartment.excluded_models.concat(configuration.additional_apartment_models) if configuration.additional_apartment_models.class == Array
return configuration
end
|
.custom_logger(name: "", level: Rails.logger.present? ? Rails.logger.level : MonoLogger::INFO, type: :ougai) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/zuora_connect.rb', line 30
def custom_logger(name: "", level: Rails.logger.present? ? Rails.logger.level : MonoLogger::INFO, type: :ougai)
if type == :ougai
require 'ougai'
logger = Ougai::Logger.new(STDOUT)
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
logger.level = level
logger.before_log = lambda do |data|
data[:trace_id] = ZuoraConnect::RequestIdMiddleware.request_id if ZuoraConnect::RequestIdMiddleware.request_id.present?
data[:zuora_trace_id] = ZuoraConnect::RequestIdMiddleware.zuora_request_id if ZuoraConnect::RequestIdMiddleware.zuora_request_id.present?
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool', 'Resque', 'Makara'].include?(name)
if Thread.current[:appinstance].present?
data[:app_instance_id] = Thread.current[:appinstance].id
logitems = Thread.current[:appinstance].logitems
if logitems.present? && logitems.class == Hash
data[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
data[:organization] = logitems[:organization] if logitems[:organization].present?
end
end
end
end
else
logger = MonoLogger.new(STDOUT)
logger.level = level
logger.formatter = proc do |serverity, datetime, progname, msg|
begin
msg = JSON.parse(msg)
rescue JSON::ParserError => ex
end
require 'json'
store = {
name: name,
level: serverity,
timestamp: datetime.strftime('%FT%T.%6NZ'),
pid: Process.pid,
message: name == "ActionMailer" ? msg.strip : msg
}
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool','Resque', 'Makara'].include?(name)
if Thread.current[:appinstance].present?
store[:app_instance_id] = Thread.current[:appinstance].id
logitems = Thread.current[:appinstance].logitems
if logitems.present? && logitems.class == Hash
store[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
store[:organization] = logitems[:organization] if logitems[:organization].present?
end
end
end
JSON.dump(store) + "\n"
end
end
return logger
end
|
.elastic_apm_defaults ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/zuora_connect.rb', line 111
def self.elastic_apm_defaults
defaults = {}
case Rails.env.to_s
when 'production'
defaults = {
server_url: "http://apm-server.logging:8200",
transaction_sample_rate: 0.20,
capture_body: 'errors'
}
when 'staging'
defaults = {
server_url: "http://apm-server.logging:8200",
transaction_sample_rate: 1.0
}
when 'development'
defaults = {
server_url: "http://logging.0.ecc.auw2.zuora:8200",
transaction_sample_rate: 1.0
}
when 'test'
defaults = {
active: false,
disable_send: true
}
end
defaults.merge!({
disable_start_message: true,
pool_size: 1,
transaction_max_spans: 500,
ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
verify_server_cert: false,
log_level: Logger::INFO,
service_name: ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : Rails.application.class.parent_name,
logger: ZuoraConnect.custom_logger(name: "ElasticAPM", level: MonoLogger::WARN)
})
defaults.merge!({disable_send: true}) if defined?(Rails::Console)
return defaults
end
|
.reset ⇒ Object
99
100
101
|
# File 'lib/zuora_connect.rb', line 99
def self.reset
@configuration = Configuration.new
end
|