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
- .app_name ⇒ 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.
30 31 32 |
# File 'lib/ting_yun/configuration/default_source.rb', line 30 def initialize @defaults = default_values end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
24 25 26 |
# File 'lib/ting_yun/configuration/default_source.rb', line 24 def defaults @defaults end |
Class Method Details
.action_tracer_action_threshold ⇒ Object
106 107 108 |
# File 'lib/ting_yun/configuration/default_source.rb', line 106 def self.action_tracer_action_threshold Proc.new { TingYun::Agent.config[:apdex_t] * 4 } end |
.app_name ⇒ Object
98 99 100 |
# File 'lib/ting_yun/configuration/default_source.rb', line 98 def self.app_name Proc.new { ::TingYun::Frameworks.framework.env } end |
.config_path ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/ting_yun/configuration/default_source.rb', line 64 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
110 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 |
# File 'lib/ting_yun/configuration/default_source.rb', line 110 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
86 87 88 |
# File 'lib/ting_yun/configuration/default_source.rb', line 86 def self.dispatcher Proc.new { ::TingYun::Frameworks.framework.local_env.discovered_dispatcher } end |
.empty_array ⇒ Object
73 74 75 |
# File 'lib/ting_yun/configuration/default_source.rb', line 73 def self.empty_array Proc.new { [] } end |
.framework ⇒ Object
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 |
# File 'lib/ting_yun/configuration/default_source.rb', line 34 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 when 5 :rails5 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.
93 94 95 |
# File 'lib/ting_yun/configuration/default_source.rb', line 93 def self.normalize_json_string_encodings Proc.new { TingYun::Support::LanguageSupport.supports_string_encodings? } end |
Instance Method Details
#default_values ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/ting_yun/configuration/default_source.rb', line 78 def default_values result = {} ::TingYun::Configuration::DEFAULTS.each do |key, value| result[key] = value[:default] end result end |