lib/flipper/adapters/instrumented.rb in flipper-0.11.0.beta3 vs lib/flipper/adapters/instrumented.rb in flipper-0.11.0.beta4
- old
+ new
@@ -2,11 +2,11 @@
require 'flipper/instrumenters/noop'
module Flipper
module Adapters
# Internal: Adapter that wraps another adapter and instruments all adapter
- # operations. Used by flipper dsl to provide instrumentatin for flipper.
+ # operations.
class Instrumented < SimpleDelegator
include ::Flipper::Adapter
# Private: The name of instrumentation events.
InstrumentationName = "adapter_operation.#{InstrumentationNamespace}".freeze
@@ -90,9 +90,32 @@
feature_name: feature.name,
}
@instrumenter.instrument(InstrumentationName, payload) do |payload|
payload[:result] = @adapter.get(feature)
+ end
+ end
+
+ def get_multi(features)
+ payload = {
+ operation: :get_multi,
+ adapter_name: @adapter.name,
+ feature_names: features.map(&:name),
+ }
+
+ @instrumenter.instrument(InstrumentationName, payload) do |payload|
+ payload[:result] = @adapter.get_multi(features)
+ end
+ end
+
+ def get_all
+ payload = {
+ operation: :get_all,
+ adapter_name: @adapter.name,
+ }
+
+ @instrumenter.instrument(InstrumentationName, payload) do |payload|
+ payload[:result] = @adapter.get_all
end
end
# Public
def enable(feature, gate, thing)