Class: StackifyRubyAPM::Config Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::Config
- Includes:
- Log
- Defined in:
- lib/stackify_apm/config.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ config_file: 'config/stackify_apm.yml', json_config_file: 'config/stackify.json', rum_script_src: 'https://stckjs.azureedge.net/stckjs.js', application_name: 'Ruby Application', environment_name: ENV['RAILS_ENV'] || ENV['RACK_ENV'], already_instrumented_flag: false, rum_auto_injection: false, rum_enabled: true, rum_cookie_path: '/', rum_cookie_name: '.Stackify.Rum', transport: StackifyRubyAPM::TRACE_LOG, instrument: true, debug_logging: false, log_path: StackifyRubyAPM::Util.host_os == 'WINDOWS' ? 'C:\ProgramData\Stackify\Ruby\log\stackify-ruby-apm-1.log' : '/usr/local/stackify/stackify-ruby-apm/log/stackify-ruby-apm-1.log', log_level: Logger::INFO, log_trace_path: StackifyRubyAPM::Util.host_os == 'WINDOWS' ? 'C:\ProgramData\Stackify\Ruby\log\\' : '/usr/local/stackify/stackify-ruby-apm/log/', max_queue_size: 500, # Maximum queue length of transactions before sending transactions to the APM. flush_interval_seconds: 1, # interval with which transactions should be sent to the APM. Default value: 1 seconds delay_seconds: 10, # Interval in seconds between tries max_retries: 3, # Number of attempts filter_exception_types: [], tracer_logger: nil, logger_byte_size: 50_000_000, # e.g, 50_000_000=50mb filenum_rotate: 20, debugger_byte_size: 20_000_000, # e.g, 20_000_000=20mb debugger_filenum_rotate: 3, logtime_created: 0, http_status: nil, debug_transactions: false, trace_log_age_in_hour: 60 * 60, # e.g, 60*60=1hour, 60*2=2mins check_trace_log_per_hour: '1h', # e.g, 1h=every 1hour, 2m=every 2mins source_lines_error_app_frames: 5, source_lines_span_app_frames: 5, source_lines_error_library_frames: 0, source_lines_span_library_frames: 0, span_frames_min_duration: -1, # it will collect stack traces for all spans disabled_spies: %w[json], view_paths: [], root_path: Dir.pwd, stackify_properties_file: '/usr/local/stackify/stackify-ruby-apm/stackify.properties', agent_traces_url: '/traces', unix_socket_path: '/usr/local/stackify/stackify.sock', transport_http_endpoint: 'https://localhost:10601', queue: true, lambda_handler: '', prefix_enabled: false }.freeze
- ENV_TO_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'STACKIFY_DEBUG' => [:bool, 'debug_logging'], 'STACKIFY_APPLICATION_NAME' => 'application_name', 'STACKIFY_ENVIRONMENT_NAME' => 'environment_name', 'STACKIFY_RUM' => [:bool, 'rum_enabled'], 'STACKIFY_RUM_AUTO_INJECT' => [:bool, 'rum_auto_injection'], 'STACKIFY_RUM_SCRIPT_SRC' => 'rum_script_src', 'STACKIFY_TRANSPORT' => 'transport', 'STACKIFY_TRANSPORT_LOG_PATH' => 'log_path', 'STACKIFY_TRANSPORT_LOG_LEVEL' => [:int, 'log_level'], 'STACKIFY_TRANSPORT_SOCKET_PATH' => 'unix_socket_path', 'STACKIFY_TRANSPORT_HTTP_ENDPOINT' => 'transport_http_endpoint', 'STACKIFY_ALREADY_INSTRUMENTED_FLAG' => 'already_instrumented_flag', 'STACKIFY_INSTRUMENT' => [:bool, 'instrument'], 'STACKIFY_HOSTNAME' => 'hostname', 'STACKIFY_SOURCE_LINES_ERROR_APP_FRAMES' => [:int, 'source_lines_error_app_frames'], 'STACKIFY_SOURCE_LINES_SPAN_APP_FRAMES' => [:int, 'source_lines_span_app_frames'], 'STACKIFY_SOURCE_LINES_ERROR_LIBRARY_FRAMES' => [:int, 'source_lines_error_library_frames'], 'STACKIFY_SOURCE_LINES_SPAN_LIBRARY_FRAMES' => [:int, 'source_lines_span_library_frames'], 'STACKIFY_SPAN_FRAMES_MIN_DURATION' => [:int, 'span_frames_min_duration'], 'STACKIFY_MAX_QUEUE_SIZE' => [:int, 'max_queue_size'], 'STACKIFY_FLUSH_INTERVAL' => 'flush_interval_seconds', 'STACKIFY_DISABLED_SPIES' => [:list, 'disabled_spies'], 'STACKIFY_QUEUE' => [:bool, 'queue'], 'STACKIFY_LAMBDA_HANDLER' => 'lambda_handler', 'STACKIFY_PREFIX_ENABLED' => [:bool, 'prefix_enabled'] }.freeze
Constants included from Log
Instance Attribute Summary collapse
- #agent_traces_url ⇒ Object private
- #already_instrumented_flag ⇒ Object private
- #apm_disabled_in_rake ⇒ Object readonly private
- #application_name ⇒ Object private
- #check_trace_log_per_hour ⇒ Object private
- #client_id ⇒ Object readonly private
- #client_run_domain ⇒ Object readonly private
- #config_file ⇒ Object private
- #debug_logging ⇒ Object private
- #debug_transactions ⇒ Object private
- #debugger_byte_size ⇒ Object private
- #debugger_filenum_rotate ⇒ Object private
- #delay_seconds ⇒ Object private
- #device_id ⇒ Object readonly private
- #disabled_spies ⇒ Object private
- #enabled_environments ⇒ Object private
- #environment_name ⇒ Object private
- #filenum_rotate ⇒ Object private
- #filter_exception_types ⇒ Object private
- #flush_interval_seconds ⇒ Object private
- #hostname ⇒ Object private
- #http_status ⇒ Object private
- #instrument ⇒ Object private
- #json_config_file ⇒ Object private
- #lambda_handler ⇒ Object private
- #log_level ⇒ Object private
- #log_path ⇒ Object private
- #log_trace_path ⇒ Object private
- #logger ⇒ Object private
- #logger_byte_size ⇒ Object private
- #logtime_created ⇒ Object private
- #max_queue_size ⇒ Object private
- #max_retries ⇒ Object private
- #prefix_enabled ⇒ Object private
- #queue ⇒ Object private
- #root_path ⇒ Object private
- #rum_auto_injection ⇒ Object private
- #rum_cookie_name ⇒ Object private
- #rum_cookie_path ⇒ Object private
- #rum_enabled ⇒ Object private
- #rum_script_injected ⇒ Object private
- #rum_script_src ⇒ Object private
- #source_lines_error_app_frames ⇒ Object private
- #source_lines_error_library_frames ⇒ Object private
- #source_lines_span_app_frames ⇒ Object private
- #source_lines_span_library_frames ⇒ Object private
- #span_frames_min_duration ⇒ Object private
- #stackify_properties_file ⇒ Object private
- #trace_log_age_in_hour ⇒ Object private
- #tracer_logger ⇒ Object private
- #transport ⇒ Object private
- #transport_http_endpoint ⇒ Object private
- #unix_socket_path ⇒ Object private
- #view_paths ⇒ Object private
Instance Method Summary collapse
- #app=(app) ⇒ Object private
- #app_type?(app) ⇒ Boolean private
-
#available_spies ⇒ Object
private
available spies to use when framework is rails.
-
#debug_logger ⇒ Object
private
Default Transport.
- #enabled_spies ⇒ Object private
-
#initialize(options = {}) {|_self| ... } ⇒ Config
constructor
private
A new instance of Config.
- #prefix_spies ⇒ Object private
Methods included from Log
#debug, #error, #fatal, #info, #log, #warn
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Config
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Config.
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/stackify_apm/config.rb', line 105 def initialize( = {}) set_defaults set_from_args() set_from_config_file set_from_env set_prefix_paths if @prefix_enabled yield self if block_given? debug_logger StackifyRubyAPM::Util.host_os == 'WINDOWS' ? load_stackify_props_windows : load_stackify_props_linux validate_apm_yml end |
Instance Attribute Details
#agent_traces_url ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
131 132 133 |
# File 'lib/stackify_apm/config.rb', line 131 def agent_traces_url @agent_traces_url end |
#already_instrumented_flag ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
125 126 127 |
# File 'lib/stackify_apm/config.rb', line 125 def already_instrumented_flag @already_instrumented_flag end |
#apm_disabled_in_rake ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
180 181 182 |
# File 'lib/stackify_apm/config.rb', line 180 def apm_disabled_in_rake @apm_disabled_in_rake end |
#application_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 |
# File 'lib/stackify_apm/config.rb', line 135 def application_name @application_name end |
#check_trace_log_per_hour ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
147 148 149 |
# File 'lib/stackify_apm/config.rb', line 147 def check_trace_log_per_hour @check_trace_log_per_hour end |
#client_id ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
178 179 180 |
# File 'lib/stackify_apm/config.rb', line 178 def client_id @client_id end |
#client_run_domain ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
181 182 183 |
# File 'lib/stackify_apm/config.rb', line 181 def client_run_domain @client_run_domain end |
#config_file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 |
# File 'lib/stackify_apm/config.rb', line 117 def config_file @config_file end |
#debug_logging ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
141 142 143 |
# File 'lib/stackify_apm/config.rb', line 141 def debug_logging @debug_logging end |
#debug_transactions ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
166 167 168 |
# File 'lib/stackify_apm/config.rb', line 166 def debug_transactions @debug_transactions end |
#debugger_byte_size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
144 145 146 |
# File 'lib/stackify_apm/config.rb', line 144 def debugger_byte_size @debugger_byte_size end |
#debugger_filenum_rotate ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
145 146 147 |
# File 'lib/stackify_apm/config.rb', line 145 def debugger_filenum_rotate @debugger_filenum_rotate end |
#delay_seconds ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/stackify_apm/config.rb', line 161 def delay_seconds @delay_seconds end |
#device_id ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
179 180 181 |
# File 'lib/stackify_apm/config.rb', line 179 def device_id @device_id end |
#disabled_spies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
168 169 170 |
# File 'lib/stackify_apm/config.rb', line 168 def disabled_spies @disabled_spies end |
#enabled_environments ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
128 129 130 |
# File 'lib/stackify_apm/config.rb', line 128 def enabled_environments @enabled_environments end |
#environment_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
119 120 121 |
# File 'lib/stackify_apm/config.rb', line 119 def environment_name @environment_name end |
#filenum_rotate ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
143 144 145 |
# File 'lib/stackify_apm/config.rb', line 143 def filenum_rotate @filenum_rotate end |
#filter_exception_types ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
164 165 166 |
# File 'lib/stackify_apm/config.rb', line 164 def filter_exception_types @filter_exception_types end |
#flush_interval_seconds ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
160 161 162 |
# File 'lib/stackify_apm/config.rb', line 160 def flush_interval_seconds @flush_interval_seconds end |
#hostname ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
136 137 138 |
# File 'lib/stackify_apm/config.rb', line 136 def hostname @hostname end |
#http_status ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
172 173 174 |
# File 'lib/stackify_apm/config.rb', line 172 def http_status @http_status end |
#instrument ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
127 128 129 |
# File 'lib/stackify_apm/config.rb', line 127 def instrument @instrument end |
#json_config_file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
118 119 120 |
# File 'lib/stackify_apm/config.rb', line 118 def json_config_file @json_config_file end |
#lambda_handler ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
175 176 177 |
# File 'lib/stackify_apm/config.rb', line 175 def lambda_handler @lambda_handler end |
#log_level ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 |
# File 'lib/stackify_apm/config.rb', line 139 def log_level @log_level end |
#log_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
138 139 140 |
# File 'lib/stackify_apm/config.rb', line 138 def log_path @log_path end |
#log_trace_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
152 153 154 |
# File 'lib/stackify_apm/config.rb', line 152 def log_trace_path @log_trace_path end |
#logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 |
# File 'lib/stackify_apm/config.rb', line 140 def logger @logger end |
#logger_byte_size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
142 143 144 |
# File 'lib/stackify_apm/config.rb', line 142 def logger_byte_size @logger_byte_size end |
#logtime_created ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
150 151 152 |
# File 'lib/stackify_apm/config.rb', line 150 def logtime_created @logtime_created end |
#max_queue_size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
159 160 161 |
# File 'lib/stackify_apm/config.rb', line 159 def max_queue_size @max_queue_size end |
#max_retries ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
162 163 164 |
# File 'lib/stackify_apm/config.rb', line 162 def max_retries @max_retries end |
#prefix_enabled ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
176 177 178 |
# File 'lib/stackify_apm/config.rb', line 176 def prefix_enabled @prefix_enabled end |
#queue ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
174 175 176 |
# File 'lib/stackify_apm/config.rb', line 174 def queue @queue end |
#root_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
171 172 173 |
# File 'lib/stackify_apm/config.rb', line 171 def root_path @root_path end |
#rum_auto_injection ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
121 122 123 |
# File 'lib/stackify_apm/config.rb', line 121 def rum_auto_injection @rum_auto_injection end |
#rum_cookie_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 |
# File 'lib/stackify_apm/config.rb', line 124 def @rum_cookie_name end |
#rum_cookie_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'lib/stackify_apm/config.rb', line 123 def @rum_cookie_path end |
#rum_enabled ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 |
# File 'lib/stackify_apm/config.rb', line 122 def rum_enabled @rum_enabled end |
#rum_script_injected ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
126 127 128 |
# File 'lib/stackify_apm/config.rb', line 126 def rum_script_injected @rum_script_injected end |
#rum_script_src ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
120 121 122 |
# File 'lib/stackify_apm/config.rb', line 120 def rum_script_src @rum_script_src end |
#source_lines_error_app_frames ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
153 154 155 |
# File 'lib/stackify_apm/config.rb', line 153 def source_lines_error_app_frames @source_lines_error_app_frames end |
#source_lines_error_library_frames ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
155 156 157 |
# File 'lib/stackify_apm/config.rb', line 155 def source_lines_error_library_frames @source_lines_error_library_frames end |
#source_lines_span_app_frames ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
154 155 156 |
# File 'lib/stackify_apm/config.rb', line 154 def source_lines_span_app_frames @source_lines_span_app_frames end |
#source_lines_span_library_frames ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
156 157 158 |
# File 'lib/stackify_apm/config.rb', line 156 def source_lines_span_library_frames @source_lines_span_library_frames end |
#span_frames_min_duration ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
157 158 159 |
# File 'lib/stackify_apm/config.rb', line 157 def span_frames_min_duration @span_frames_min_duration end |
#stackify_properties_file ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
129 130 131 |
# File 'lib/stackify_apm/config.rb', line 129 def stackify_properties_file @stackify_properties_file end |
#trace_log_age_in_hour ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
146 147 148 |
# File 'lib/stackify_apm/config.rb', line 146 def trace_log_age_in_hour @trace_log_age_in_hour end |
#tracer_logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
149 150 151 |
# File 'lib/stackify_apm/config.rb', line 149 def tracer_logger @tracer_logger end |
#transport ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 |
# File 'lib/stackify_apm/config.rb', line 130 def transport @transport end |
#transport_http_endpoint ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
133 134 135 |
# File 'lib/stackify_apm/config.rb', line 133 def transport_http_endpoint @transport_http_endpoint end |
#unix_socket_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
132 133 134 |
# File 'lib/stackify_apm/config.rb', line 132 def unix_socket_path @unix_socket_path end |
#view_paths ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
170 171 172 |
# File 'lib/stackify_apm/config.rb', line 170 def view_paths @view_paths end |
Instance Method Details
#app=(app) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
183 184 185 186 187 188 189 190 191 |
# File 'lib/stackify_apm/config.rb', line 183 def app=(app) case app_type?(app) when :rails set_rails(app) else # TODO: define custom? self.application_name = 'ruby' end end |
#app_type?(app) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
193 194 195 196 197 |
# File 'lib/stackify_apm/config.rb', line 193 def app_type?(app) return :rails if defined?(::Rails) && app.is_a?(Rails::Application) nil end |
#available_spies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
available spies to use when framework is rails
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/stackify_apm/config.rb', line 200 def available_spies %w[ action_dispatch mongo net_http custom_instrumenter httpclient redis sequel tilt httprb curb curb/easy curb/multi httparty stackify_logger sidekiq delayed_job faraday sucker_punch dynamo_db ] end |
#debug_logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Default Transport
initialize default logger transport
259 260 261 262 263 264 265 266 267 268 |
# File 'lib/stackify_apm/config.rb', line 259 def debug_logger case @transport.downcase # For unix socket we don't create a trace log file when StackifyRubyAPM::TRACE_LOG debugger_logpath = log_path == '-' ? $stdout : log_path logger = StackifyLogger.new(debugger_logpath, debugger_filenum_rotate, debugger_byte_size) logger.level = log_level self.logger = logger end end |
#enabled_spies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/stackify_apm/config.rb', line 234 def enabled_spies # check if the framework is rails or sinatra sinatra_activerecord_spies = %w[ sinatra sinatra_activerecord/mysql_adapter sinatra_activerecord/postgresql_adapter sinatra_activerecord/sqlite_adapter ] new_available_spies = if defined? ::Sinatra::Base if defined? ActiveRecord available_spies + sinatra_activerecord_spies else available_spies end else available_spies end new_available_spies + prefix_spies - disabled_spies end |
#prefix_spies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
224 225 226 227 228 229 230 231 232 |
# File 'lib/stackify_apm/config.rb', line 224 def prefix_spies return [] unless @prefix_enabled %w[ logger logging log4r yell ] end |