Class: Contrast::Components::Ruby::Interface

Inherits:
Object
  • Object
show all
Includes:
ComponentBase
Defined in:
lib/contrast/components/ruby_component.rb

Overview

A wrapper build around the Common Agent Configuration project to allow for access of the values contained in its parent_configuration_spec.yaml. Those in this section pertain to the specific settings that apply to Ruby.

Constant Summary collapse

DISABLED_RAKE_TASK_LIST =
%w[
  about assets:clean assets:clobber assets:environment
  assets:precompile assets:precompile:all db:create db:drop db:fixtures:load db:migrate
  db:migrate:status db:rollback db:schema:cache:clear db:schema:cache:dump db:schema:dump
  db:schema:load db:seed db:setup db:structure:dump db:version doc:app graphql:install graphql:object
  log:clear middleware notes notes:custom rails:template rails:update routes secret spec spec:features
  spec:requests spec:controllers spec:helpers spec:models spec:views spec:routing spec:rcov stats
  test test:all test:all:db test:recent test:single test:uncommitted time:zones:all tmp:clear
  tmp:create webpacker:compile
].cs__freeze
DEFAULT_UNINSTRUMENTED_NAMESPACES =
%w[FactoryGirl FactoryBot].cs__freeze
CANON_NAME =
'agent.ruby'
CONFIG_VALUES =
%w[
  disabled_agent_rake_tasks
  propagate_yield require_scan
  non_request_tracking
  uninstrument_namespace
  application_scope
].cs__freeze

Constants included from ComponentBase

ComponentBase::ENABLE

Constants included from Contrast::Config::Diagnostics::Tools

Contrast::Config::Diagnostics::Tools::CHECK

Constants included from Contrast::Config::Diagnostics::SingletonTools

Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComponentBase

#false?, #file_exists?, #stringify_array, #to_effective_config, #true?, #valid_cert?

Methods included from Contrast::Config::Diagnostics::Tools

#add_effective_config_values, #add_single_effective_value

Methods included from Contrast::Config::Diagnostics::SingletonTools

#flatten_settings, #to_config_values, #update_config, #value_to_s

Constructor Details

#initialize(hsh = {}) ⇒ Interface

Returns a new instance of Interface.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/contrast/components/ruby_component.rb', line 69

def initialize hsh = {}
  @config_values = CONFIG_VALUES
  @canon_name = CANON_NAME
  return unless hsh

  @disabled_agent_rake_tasks = hsh[:disabled_agent_rake_tasks]
  @exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
  @propagate_yield = hsh[:propagate_yield]
  @require_scan = hsh[:require_scan]
  @non_request_tracking = hsh[:non_request_tracking]
  @uninstrument_namespace = hsh[:uninstrument_namespace]
  # This value must only be read form ENV. The cs__with_app_scope? method handles the
  # validation of the set Application Scope Flag.
  @application_scope = Contrast::Components::Scope.cs__with_app_scope? == 1
end

Instance Attribute Details

#application_scopeObject

Controls if the agent should instrument only the application code

@return



62
63
64
# File 'lib/contrast/components/ruby_component.rb', line 62

def application_scope
  @application_scope
end

#canon_nameString (readonly)

Returns:



65
66
67
# File 'lib/contrast/components/ruby_component.rb', line 65

def canon_name
  @canon_name
end

#config_valuesArray (readonly)

Returns:

  • (Array)


67
68
69
# File 'lib/contrast/components/ruby_component.rb', line 67

def config_values
  @config_values
end

#disabled_agent_rake_tasksArray, DISABLED_RAKE_TASK_LIST

These commands being detected will result the agent disabling instrumentation, generally any command that doesn’t result in the application listening on a port can be added here, this normally includes tasks that are ran pre-startup(like migrations) or to show information about the application(such as routes)

Returns:



89
90
91
# File 'lib/contrast/components/ruby_component.rb', line 89

def disabled_agent_rake_tasks
  @disabled_agent_rake_tasks.nil? ? DISABLED_RAKE_TASK_LIST : @disabled_agent_rake_tasks
end

#exceptionsContrast::Config::ExceptionConfiguration

rubocop:disable Naming/MemoizedInstanceVariableName



95
96
97
# File 'lib/contrast/components/ruby_component.rb', line 95

def exceptions
  @exceptions ||= Contrast::Config::ExceptionConfiguration.new
end

#non_request_trackingBoolean, Contrast::Utils::ObjectShare::FALSE

controls tracking outside of request



114
115
116
# File 'lib/contrast/components/ruby_component.rb', line 114

def non_request_tracking
  @non_request_tracking.nil? ? Contrast::Utils::ObjectShare::FALSE : @non_request_tracking
end

#propagate_yieldBoolean, Contrast::Utils::ObjectShare::TRUE

controls whether or not we patch the rb_yield block to track split propagation



102
103
104
# File 'lib/contrast/components/ruby_component.rb', line 102

def propagate_yield
  @propagate_yield.nil? ? Contrast::Utils::ObjectShare::TRUE : @propagate_yield
end

#require_scanBoolean, Contrast::Utils::ObjectShare::TRUE

control whether or not we run file scanning rules on require



108
109
110
# File 'lib/contrast/components/ruby_component.rb', line 108

def require_scan
  @require_scan.nil? ?  Contrast::Utils::ObjectShare::TRUE  : @require_scan
end

#uninstrument_namespaceArray, DEFAULT_UNINSTRUMENTED_NAMESPACES



119
120
121
# File 'lib/contrast/components/ruby_component.rb', line 119

def uninstrument_namespace
  @uninstrument_namespace.nil? ? DEFAULT_UNINSTRUMENTED_NAMESPACES : @uninstrument_namespace
end

Instance Method Details

#start_with_application_scope?Boolean

Checks to see if we support with_app_scope for the current Agent Startup. Defaults to false if configuration is not set.

Returns:

  • (Boolean)


127
128
129
130
131
# File 'lib/contrast/components/ruby_component.rb', line 127

def start_with_application_scope?
  return application_scope if application_scope

  false
end