Module: Oboe::Config
- Defined in:
- lib/oboe/config.rb
Overview
This module exposes a nested configuration hash that can be used to configure and/or modify the functionality of the oboe gem.
Use Oboe::Config.show to view the entire nested hash.
Constant Summary collapse
- @@config =
{}
- @@instrumentation =
[ :cassandra, :dalli, :nethttp, :memcached, :memcache, :mongo, :moped, :rack, :resque, :action_controller, :action_view, :active_record ]
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, value) ⇒ Object
- .initialize(data = {}) ⇒ Object
- .method_missing(sym, *args) ⇒ Object
-
.show ⇒ Object
Return the raw nested hash.
- .update!(data) ⇒ Object
Class Method Details
.[](key) ⇒ Object
83 84 85 |
# File 'lib/oboe/config.rb', line 83 def self.[](key) @@config[key.to_sym] end |
.[]=(key, value) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/oboe/config.rb', line 87 def self.[]=(key, value) @@config[key.to_sym] = value if key == :sampling_rate Oboe.logger.warn "WARNING: :sampling_rate is not a supported setting for Oboe::Config. Please use :sample_rate." end if key == :sample_rate # When setting SampleRate, note that it's been manually set # OBOE_SAMPLE_RATE_SOURCE_FILE == 1 @@config[:sample_source] = 1 unless value.is_a?(Integer) or value.is_a?(Float) raise "oboe :sample_rate must be a number between 1 and 1000000 (1m)" end # Validate :sample_rate value unless value.between?(1, 1e6) raise "oboe :sample_rate must be between 1 and 1000000 (1m)" end # Assure value is an integer @@config[key.to_sym] = value.to_i Oboe.set_sample_rate(value) end # Update liboboe if updating :tracing_mode if key == :tracing_mode Oboe.set_tracing_mode(value) end end |
.initialize(data = {}) ⇒ Object
25 26 27 28 29 30 31 32 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/oboe/config.rb', line 25 def self.initialize(data={}) # Setup default instrumentation values @@instrumentation.each do |k| @@config[k] = {} @@config[k][:enabled] = true @@config[k][:collect_backtraces] = false @@config[k][:log_args] = true end # Set collect_backtraces defaults Oboe::Config[:action_controller][:collect_backtraces] = true Oboe::Config[:active_record][:collect_backtraces] = true Oboe::Config[:action_view][:collect_backtraces] = true Oboe::Config[:cassandra][:collect_backtraces] = true Oboe::Config[:dalli][:collect_backtraces] = false Oboe::Config[:memcache][:collect_backtraces] = false Oboe::Config[:memcached][:collect_backtraces] = false Oboe::Config[:mongo][:collect_backtraces] = true Oboe::Config[:moped][:collect_backtraces] = true Oboe::Config[:nethttp][:collect_backtraces] = true Oboe::Config[:resque][:collect_backtraces] = true # Special instrument specific flags # # :link_workers - associates enqueue operations with the jobs they queue by piggybacking # an additional argument that is stripped prior to job proecessing # !!Note: Make sure both the queue side and the Resque workers are instrumented # or jobs will fail # (Default: false) @@config[:resque][:link_workers] = false # Setup an empty host blacklist (see: Oboe::API::Util.blacklisted?) @@config[:blacklist] = [] # The oboe Ruby client has the ability to sanitize query literals # from SQL statements. By default this is disabled. Enable to # avoid collecting and reporting query literals to TraceView. @@config[:sanitize_sql] = false # The default configuration default_config = { :tracing_mode => "through", :reporter_host => "127.0.0.1", :sample_rate => 300000, :verbose => false } update!(default_config) # For Initialization, mark this as the default SampleRate @@config[:sample_source] = 2 # OBOE_SAMPLE_RATE_SOURCE_DEFAULT end |
.method_missing(sym, *args) ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/oboe/config.rb', line 120 def self.method_missing(sym, *args) if sym.to_s =~ /(.+)=$/ self[$1] = args.first else self[sym] end end |
.show ⇒ Object
Return the raw nested hash.
21 22 23 |
# File 'lib/oboe/config.rb', line 21 def self.show @@config end |
.update!(data) ⇒ Object
77 78 79 80 81 |
# File 'lib/oboe/config.rb', line 77 def self.update!(data) data.each do |key, value| self[key] = value end end |