Class: Flipper::Adapters::Instrumented
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Flipper::Adapters::Instrumented
- Includes:
- Flipper::Adapter
- Defined in:
- lib/flipper/adapters/instrumented.rb
Overview
Internal: Adapter that wraps another adapter and instruments all adapter operations. Used by flipper dsl to provide instrumentatin for flipper.
Constant Summary collapse
- InstrumentationName =
Private: The name of instrumentation events.
"adapter_operation.#{InstrumentationNamespace}".freeze
Instance Attribute Summary collapse
-
#instrumenter ⇒ Object
readonly
Private: What is used to instrument all the things.
-
#name ⇒ Object
readonly
Public: The name of the adapter.
Instance Method Summary collapse
-
#add(feature) ⇒ Object
Public.
-
#clear(feature) ⇒ Object
Public.
-
#disable(feature, gate, thing) ⇒ Object
Public.
-
#enable(feature, gate, thing) ⇒ Object
Public.
-
#features ⇒ Object
Public.
-
#get(feature) ⇒ Object
Public.
-
#initialize(adapter, options = {}) ⇒ Instrumented
constructor
Internal: Initializes a new adapter instance.
-
#remove(feature) ⇒ Object
Public.
Constructor Details
#initialize(adapter, options = {}) ⇒ Instrumented
Internal: Initializes a new adapter instance.
adapter - Vanilla adapter instance to wrap.
options - The Hash of options.
:instrumenter - What to use to instrument all the things.
27 28 29 30 31 32 |
# File 'lib/flipper/adapters/instrumented.rb', line 27 def initialize(adapter, = {}) super(adapter) @adapter = adapter @name = :instrumented @instrumenter = .fetch(:instrumenter, Instrumenters::Noop) end |
Instance Attribute Details
#instrumenter ⇒ Object (readonly)
Private: What is used to instrument all the things.
15 16 17 |
# File 'lib/flipper/adapters/instrumented.rb', line 15 def instrumenter @instrumenter end |
#name ⇒ Object (readonly)
Public: The name of the adapter.
18 19 20 |
# File 'lib/flipper/adapters/instrumented.rb', line 18 def name @name end |
Instance Method Details
#add(feature) ⇒ Object
Public
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flipper/adapters/instrumented.rb', line 47 def add(feature) payload = { :operation => :add, :adapter_name => @adapter.name, :feature_name => feature.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.add(feature) } end |
#clear(feature) ⇒ Object
Public
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/flipper/adapters/instrumented.rb', line 73 def clear(feature) payload = { :operation => :clear, :adapter_name => @adapter.name, :feature_name => feature.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.clear(feature) } end |
#disable(feature, gate, thing) ⇒ Object
Public
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/flipper/adapters/instrumented.rb', line 113 def disable(feature, gate, thing) payload = { :operation => :disable, :adapter_name => @adapter.name, :feature_name => feature.name, :gate_name => gate.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.disable(feature, gate, thing) } end |
#enable(feature, gate, thing) ⇒ Object
Public
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/flipper/adapters/instrumented.rb', line 99 def enable(feature, gate, thing) payload = { :operation => :enable, :adapter_name => @adapter.name, :feature_name => feature.name, :gate_name => gate.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.enable(feature, gate, thing) } end |
#features ⇒ Object
Public
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/flipper/adapters/instrumented.rb', line 35 def features payload = { :operation => :features, :adapter_name => @adapter.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.features } end |
#get(feature) ⇒ Object
Public
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/flipper/adapters/instrumented.rb', line 86 def get(feature) payload = { :operation => :get, :adapter_name => @adapter.name, :feature_name => feature.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.get(feature) } end |
#remove(feature) ⇒ Object
Public
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/flipper/adapters/instrumented.rb', line 60 def remove(feature) payload = { :operation => :remove, :adapter_name => @adapter.name, :feature_name => feature.name, } @instrumenter.instrument(InstrumentationName, payload) { |payload| payload[:result] = @adapter.remove(feature) } end |