Class: TingYun::Configuration::DefaultSource
- Inherits:
-
Object
- Object
- TingYun::Configuration::DefaultSource
- Extended by:
- Forwardable
- Defined in:
- lib/ting_yun/configuration/default_source.rb
Instance Attribute Summary collapse
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Class Method Summary collapse
- .action_tracer_action_threshold ⇒ Object
- .agent_enabled ⇒ Object
- .app_name ⇒ Object
- .audit_log_path ⇒ Object
- .config_path ⇒ Object
- .config_search_paths ⇒ Object
- .dispatcher ⇒ Object
- .empty_array ⇒ Object
- .framework ⇒ Object
-
.normalize_json_string_encodings ⇒ Object
On Rubies with string encodings support (1.9.x+), default to always normalize encodings since it’s safest and fast.
- .port ⇒ Object
Instance Method Summary collapse
- #default_values ⇒ Object
-
#initialize ⇒ DefaultSource
constructor
A new instance of DefaultSource.
Constructor Details
#initialize ⇒ DefaultSource
Returns a new instance of DefaultSource.
29 30 31 |
# File 'lib/ting_yun/configuration/default_source.rb', line 29 def initialize @defaults = default_values end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
23 24 25 |
# File 'lib/ting_yun/configuration/default_source.rb', line 23 def defaults @defaults end |
Class Method Details
.action_tracer_action_threshold ⇒ Object
116 117 118 |
# File 'lib/ting_yun/configuration/default_source.rb', line 116 def self.action_tracer_action_threshold Proc.new { TingYun::Agent.config[:apdex_t] * 4 } end |
.agent_enabled ⇒ Object
110 111 112 113 114 |
# File 'lib/ting_yun/configuration/default_source.rb', line 110 def self.agent_enabled Proc.new { TingYun::Agent.config[:enabled] } end |
.app_name ⇒ Object
102 103 104 |
# File 'lib/ting_yun/configuration/default_source.rb', line 102 def self.app_name Proc.new { ::TingYun::Frameworks.framework.env } end |
.audit_log_path ⇒ Object
88 89 90 91 92 |
# File 'lib/ting_yun/configuration/default_source.rb', line 88 def self.audit_log_path Proc.new { File.join(TingYun::Agent.config[:log_file_path], 'newrelic_audit.log') } end |
.config_path ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/ting_yun/configuration/default_source.rb', line 61 def self.config_path Proc.new { found_path = TingYun::Agent.config[:config_search_paths].detect do |file| File.(file) if File.exist? file end found_path || '' } end |
.config_search_paths ⇒ Object
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 |
# File 'lib/ting_yun/configuration/default_source.rb', line 120 def self.config_search_paths Proc.new { paths = [ File.join("config", "tingyun.yml"), File.join("tingyun.yml") ] if ::TingYun::Frameworks.framework.root paths << File.join(::TingYun::Frameworks.framework.root, "config", "tingyun.yml") paths << File.join(::TingYun::Frameworks.framework.root, "tingyun.yml") end if ENV["HOME"] paths << File.join(ENV["HOME"], ".tingyun", "tingyun.yml") paths << File.join(ENV["HOME"], "tingyun.yml") end # If we're packaged for warbler, we can tell from GEM_HOME if ENV["GEM_HOME"] && ENV["GEM_HOME"].end_with?(".jar!") app_name = File.basename(ENV["GEM_HOME"], ".jar!") paths << File.join(ENV["GEM_HOME"], app_name, "config", "tingyun.yml") end paths } end |
.dispatcher ⇒ Object
83 84 85 |
# File 'lib/ting_yun/configuration/default_source.rb', line 83 def self.dispatcher Proc.new { ::TingYun::Frameworks.framework.local_env.discovered_dispatcher } end |
.empty_array ⇒ Object
70 71 72 |
# File 'lib/ting_yun/configuration/default_source.rb', line 70 def self.empty_array Proc.new { [] } end |
.framework ⇒ Object
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 |
# File 'lib/ting_yun/configuration/default_source.rb', line 33 def self.framework Proc.new { case when defined?(::TingYun::TEST) then :test when defined?(::Merb) && defined?(::Merb::Plugins) then :merb when defined?(::Rails::VERSION) case Rails::VERSION::MAJOR when 0..2 :rails when 3 :rails3 when 4 :rails4 else ::TingYun::Agent.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}" end when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra when defined?(::TingYun::IA) then :external else :ruby end } end |
.normalize_json_string_encodings ⇒ Object
On Rubies with string encodings support (1.9.x+), default to always normalize encodings since it’s safest and fast. Without that support the conversions are too expensive, so only enable if overridden to.
97 98 99 |
# File 'lib/ting_yun/configuration/default_source.rb', line 97 def self.normalize_json_string_encodings Proc.new { TingYun::Support::LanguageSupport.supports_string_encodings? } end |
Instance Method Details
#default_values ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/ting_yun/configuration/default_source.rb', line 75 def default_values result = {} ::TingYun::Configuration::DEFAULTS.each do |key, value| result[key] = value[:default] end result end |