lib/flipper/adapters/instrumented.rb in flipper-0.26.2 vs lib/flipper/adapters/instrumented.rb in flipper-0.27.0

- old
+ new

@@ -2,11 +2,11 @@ module Flipper module Adapters # Internal: Adapter that wraps another adapter and instruments all adapter # operations. - class Instrumented < SimpleDelegator + class Instrumented include ::Flipper::Adapter # Private: The name of instrumentation events. InstrumentationName = "adapter_operation.#{InstrumentationNamespace}".freeze @@ -22,11 +22,10 @@ # # options - The Hash of options. # :instrumenter - What to use to instrument all the things. # def initialize(adapter, options = {}) - super(adapter) @adapter = adapter @name = :instrumented @instrumenter = options.fetch(:instrumenter, Instrumenters::Noop) end @@ -142,9 +141,33 @@ thing_value: thing.value, } @instrumenter.instrument(InstrumentationName, default_payload) do |payload| payload[:result] = @adapter.disable(feature, gate, thing) + end + end + + def import(source) + default_payload = { + operation: :import, + adapter_name: @adapter.name, + } + + @instrumenter.instrument(InstrumentationName, default_payload) do |payload| + payload[:result] = @adapter.import(source) + end + end + + def export(format: :json, version: 1) + default_payload = { + operation: :export, + adapter_name: @adapter.name, + format: format, + version: version, + } + + @instrumenter.instrument(InstrumentationName, default_payload) do |payload| + payload[:result] = @adapter.export(format: format, version: version) end end end end end