Class: StackifyRubyAPM::Config Private

Inherits:
Object
  • Object
show all
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,
  instrument: true,
  debug_logging: false,
  log_path: '/usr/local/stackify/stackify-ruby-apm/log/stackify-ruby-apm.log',
  log_level: Logger::INFO,
  log_trace_path: '/usr/local/stackify/stackify-ruby-apm/log/',

  max_queue_size: 500, # Maximum queue length of transactions before sending transactions to the APM.
  flush_interval: 1, # interval with which transactions should be sent to the APM. Default value: 10 seconds

  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,
  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'
}.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_APM_ENVIRONMENT_NAME' => 'environment_name',
  'STACKIFY_APM_RUM_SCRIPT_SRC' => 'rum_script_src',
  'STACKIFY_APM_RUM_AUTO_INJECTION' => 'rum_auto_injection',
  'STACKIFY_ALREADY_INSTRUMENTED_FLAG' => 'already_instrumented_flag',
  'STACKIFY_APM_DEBUG_LOGGING' => 'debug_logging',
  'STACKIFY_APM_INSTRUMENT' => [:bool, 'instrument'],
  'STACKIFY_APM_HOSTNAME' => 'hostname',
  'STACKIFY_APM_LOG_PATH' => 'log_path',
  'STACKIFY_APM_LOG_LEVEL' => [:int, 'log_level'],
  'STACKIFY_APM_APPLICATION_NAME' => 'application_name',
  'STACKIFY_APM_SOURCE_LINES_ERROR_APP_FRAMES' => [:int, 'source_lines_error_app_frames'],
  'STACKIFY_APM_SOURCE_LINES_SPAN_APP_FRAMES' => [:int, 'source_lines_span_app_frames'],
  'STACKIFY_APM_SOURCE_LINES_ERROR_LIBRARY_FRAMES' => [:int, 'source_lines_error_library_frames'],
  'STACKIFY_APM_SOURCE_LINES_SPAN_LIBRARY_FRAMES' => [:int, 'source_lines_span_library_frames'],
  'STACKIFY_APM_SPAN_FRAMES_MIN_DURATION' => [:int, 'span_frames_min_duration'],
  'STACKIFY_APM_MAX_QUEUE_SIZE' => [:int, 'max_queue_size'],
  'STACKIFY_APM_FLUSH_INTERVAL' => 'flush_interval',
  'STACKIFY_APM_DISABLED_SPIES' => [:list, 'disabled_spies']
}.freeze

Constants included from Log

Log::PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Yields:

  • (_self)

Yield Parameters:



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/stackify_apm/config.rb', line 78

def initialize(options = {})
  set_defaults

  set_from_args(options)
  set_from_config_file
  set_from_env

  yield self if block_given?

  build_logger if logger.nil? || log_path
  load_stackify_props
end

Instance Attribute Details

#already_instrumented_flagObject

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.



96
97
98
# File 'lib/stackify_apm/config.rb', line 96

def already_instrumented_flag
  @already_instrumented_flag
end

#apm_disabled_in_rakeObject (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.



141
142
143
# File 'lib/stackify_apm/config.rb', line 141

def apm_disabled_in_rake
  @apm_disabled_in_rake
end

#application_nameObject

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.



102
103
104
# File 'lib/stackify_apm/config.rb', line 102

def application_name
  @application_name
end

#check_trace_log_per_hourObject

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.



114
115
116
# File 'lib/stackify_apm/config.rb', line 114

def check_trace_log_per_hour
  @check_trace_log_per_hour
end

#client_idObject (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.



139
140
141
# File 'lib/stackify_apm/config.rb', line 139

def client_id
  @client_id
end

#client_run_domainObject (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.



142
143
144
# File 'lib/stackify_apm/config.rb', line 142

def client_run_domain
  @client_run_domain
end

#config_fileObject

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.



91
92
93
# File 'lib/stackify_apm/config.rb', line 91

def config_file
  @config_file
end

#debug_loggingObject

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.



108
109
110
# File 'lib/stackify_apm/config.rb', line 108

def debug_logging
  @debug_logging
end

#debug_transactionsObject

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 debug_transactions
  @debug_transactions
end

#debugger_byte_sizeObject

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.



111
112
113
# File 'lib/stackify_apm/config.rb', line 111

def debugger_byte_size
  @debugger_byte_size
end

#debugger_filenum_rotateObject

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.



112
113
114
# File 'lib/stackify_apm/config.rb', line 112

def debugger_filenum_rotate
  @debugger_filenum_rotate
end

#device_idObject (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.



140
141
142
# File 'lib/stackify_apm/config.rb', line 140

def device_id
  @device_id
end

#disabled_spiesObject

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 disabled_spies
  @disabled_spies
end

#enabled_environmentsObject

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.



99
100
101
# File 'lib/stackify_apm/config.rb', line 99

def enabled_environments
  @enabled_environments
end

#environment_nameObject

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.



93
94
95
# File 'lib/stackify_apm/config.rb', line 93

def environment_name
  @environment_name
end

#filenum_rotateObject

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.



110
111
112
# File 'lib/stackify_apm/config.rb', line 110

def filenum_rotate
  @filenum_rotate
end

#filter_exception_typesObject

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 filter_exception_types
  @filter_exception_types
end

#flush_intervalObject

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 flush_interval
  @flush_interval
end

#hostnameObject

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.



103
104
105
# File 'lib/stackify_apm/config.rb', line 103

def hostname
  @hostname
end

#http_statusObject

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.



137
138
139
# File 'lib/stackify_apm/config.rb', line 137

def http_status
  @http_status
end

#instrumentObject

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.



98
99
100
# File 'lib/stackify_apm/config.rb', line 98

def instrument
  @instrument
end

#json_config_fileObject

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.



92
93
94
# File 'lib/stackify_apm/config.rb', line 92

def json_config_file
  @json_config_file
end

#log_levelObject

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.



106
107
108
# File 'lib/stackify_apm/config.rb', line 106

def log_level
  @log_level
end

#log_pathObject

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.



105
106
107
# File 'lib/stackify_apm/config.rb', line 105

def log_path
  @log_path
end

#log_trace_pathObject

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 log_trace_path
  @log_trace_path
end

#loggerObject

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.



107
108
109
# File 'lib/stackify_apm/config.rb', line 107

def logger
  @logger
end

#logger_byte_sizeObject

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.



109
110
111
# File 'lib/stackify_apm/config.rb', line 109

def logger_byte_size
  @logger_byte_size
end

#logtime_createdObject

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 logtime_created
  @logtime_created
end

#max_queue_sizeObject

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 max_queue_size
  @max_queue_size
end

#root_pathObject

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 root_path
  @root_path
end

#rum_auto_injectionObject

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.



95
96
97
# File 'lib/stackify_apm/config.rb', line 95

def rum_auto_injection
  @rum_auto_injection
end

#rum_script_injectedObject

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.



97
98
99
# File 'lib/stackify_apm/config.rb', line 97

def rum_script_injected
  @rum_script_injected
end

#rum_script_srcObject

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.



94
95
96
# File 'lib/stackify_apm/config.rb', line 94

def rum_script_src
  @rum_script_src
end

#source_lines_error_app_framesObject

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 source_lines_error_app_frames
  @source_lines_error_app_frames
end

#source_lines_error_library_framesObject

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 source_lines_error_library_frames
  @source_lines_error_library_frames
end

#source_lines_span_app_framesObject

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 source_lines_span_app_frames
  @source_lines_span_app_frames
end

#source_lines_span_library_framesObject

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 source_lines_span_library_frames
  @source_lines_span_library_frames
end

#span_frames_min_durationObject

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 span_frames_min_duration
  @span_frames_min_duration
end

#stackify_properties_fileObject

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.



100
101
102
# File 'lib/stackify_apm/config.rb', line 100

def stackify_properties_file
  @stackify_properties_file
end

#trace_log_age_in_hourObject

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.



113
114
115
# File 'lib/stackify_apm/config.rb', line 113

def trace_log_age_in_hour
  @trace_log_age_in_hour
end

#tracer_loggerObject

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.



116
117
118
# File 'lib/stackify_apm/config.rb', line 116

def tracer_logger
  @tracer_logger
end

#view_pathsObject

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 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.



144
145
146
147
148
149
150
151
152
# File 'lib/stackify_apm/config.rb', line 144

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.

Returns:

  • (Boolean)


154
155
156
157
158
159
160
161
162
# File 'lib/stackify_apm/config.rb', line 154

def app_type?(app)
  # if defined?(::Rails) && app.is_a?(Rails::Application)
  #   return :rails
  # end

  return :rails if defined?(::Rails) && app.is_a?(Rails::Application)

  nil
end

#available_spiesObject

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



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/stackify_apm/config.rb', line 165

def available_spies
  %w[
    action_dispatch
    mongo
    net_http
    custom_instrumenter
    httpclient
    redis
    sequel
    tilt
    httprb
    curb
    curb/easy
    curb/multi
    stackify_logger
  ]
end

#enabled_spiesObject

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
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/stackify_apm/config.rb', line 183

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 - disabled_spies
end