class Flipper::Adapters::Instrumented
Internal: Adapter
that wraps another adapter and instruments all adapter operations.
Constants
- InstrumentationName
Private: The name of instrumentation events.
Attributes
instrumenter[R]
Private: What is used to instrument all the things.
name[R]
Public: The name of the adapter.
Public Class Methods
new(adapter, options = {})
click to toggle source
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.
Calls superclass method
# File lib/flipper/adapters/instrumented.rb, line 26 def initialize(adapter, options = {}) super(adapter) @adapter = adapter @name = :instrumented @instrumenter = options.fetch(:instrumenter, Instrumenters::Noop) end
Public Instance Methods
add(feature)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 46 def add(feature) default_payload = { operation: :add, adapter_name: @adapter.name, feature_name: feature.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.add(feature) end end
clear(feature)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 72 def clear(feature) default_payload = { operation: :clear, adapter_name: @adapter.name, feature_name: feature.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.clear(feature) end end
disable(feature, gate, thing)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 136 def disable(feature, gate, thing) default_payload = { operation: :disable, adapter_name: @adapter.name, feature_name: feature.name, gate_name: gate.name, thing_value: thing.value, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.disable(feature, gate, thing) end end
enable(feature, gate, thing)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 121 def enable(feature, gate, thing) default_payload = { operation: :enable, adapter_name: @adapter.name, feature_name: feature.name, gate_name: gate.name, thing_value: thing.value, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.enable(feature, gate, thing) end end
features()
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 34 def features default_payload = { operation: :features, adapter_name: @adapter.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.features end end
get(feature)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 85 def get(feature) default_payload = { operation: :get, adapter_name: @adapter.name, feature_name: feature.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.get(feature) end end
get_all()
click to toggle source
# File lib/flipper/adapters/instrumented.rb, line 109 def get_all default_payload = { operation: :get_all, adapter_name: @adapter.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.get_all end end
get_multi(features)
click to toggle source
# File lib/flipper/adapters/instrumented.rb, line 97 def get_multi(features) default_payload = { operation: :get_multi, adapter_name: @adapter.name, feature_names: features.map(&:name), } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.get_multi(features) end end
remove(feature)
click to toggle source
Public
# File lib/flipper/adapters/instrumented.rb, line 59 def remove(feature) default_payload = { operation: :remove, adapter_name: @adapter.name, feature_name: feature.name, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.remove(feature) end end