Class: Skylight::Extensions::Collection
- Defined in:
- lib/skylight/extensions.rb
Instance Method Summary collapse
- #allowed_meta_keys ⇒ Object
- #disable!(ext_name) ⇒ Object
- #enable!(ext_name) ⇒ Object
- #enabled?(ext_name) ⇒ Boolean
-
#initialize(config, extensions = []) ⇒ Collection
constructor
A new instance of Collection.
-
#process_instrument_options(opts, meta) ⇒ Object
meta is a mutable hash that will be passed to the instrumenter.
- #process_normalizer_meta(payload, meta, **opts) ⇒ Object
- #process_trace_meta(meta) ⇒ Object
- #trace_preprocess_meta(meta) ⇒ Object
Constructor Details
#initialize(config, extensions = []) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 |
# File 'lib/skylight/extensions.rb', line 8 def initialize(config, extensions = []) @config = config @extensions = extensions end |
Instance Method Details
#allowed_meta_keys ⇒ Object
53 54 55 |
# File 'lib/skylight/extensions.rb', line 53 def @allowed_meta_keys ||= extensions.flat_map(&:allowed_meta_keys).uniq end |
#disable!(ext_name) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/skylight/extensions.rb', line 22 def disable!(ext_name) find_by_name(ext_name) do |ext_class| extensions.reject! { |x| x.is_a?(ext_class) } rememoize! end end |
#enable!(ext_name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/skylight/extensions.rb', line 13 def enable!(ext_name) return if enabled?(ext_name) find_by_name(ext_name) do |ext_class| extensions << ext_class.new(config) rememoize! end end |
#enabled?(ext_name) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/skylight/extensions.rb', line 29 def enabled?(ext_name) return unless (ext_class = find_by_name(ext_name)) !!extensions.detect { |x| x.is_a?(ext_class) } end |
#process_instrument_options(opts, meta) ⇒ Object
meta is a mutable hash that will be passed to the instrumenter. This method bridges Skylight.instrument and instrumenter.instrument.
41 42 43 |
# File 'lib/skylight/extensions.rb', line 41 def (opts, ) extensions.each { |ext| ext.(opts, ) } end |
#process_normalizer_meta(payload, meta, **opts) ⇒ Object
45 46 47 |
# File 'lib/skylight/extensions.rb', line 45 def (payload, , **opts) extensions.each { |ext| ext.(payload, , **opts) } end |
#process_trace_meta(meta) ⇒ Object
35 36 37 |
# File 'lib/skylight/extensions.rb', line 35 def () extensions.each { |ext| ext.() } end |
#trace_preprocess_meta(meta) ⇒ Object
49 50 51 |
# File 'lib/skylight/extensions.rb', line 49 def () extensions.each { |ext| ext.() } end |