Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/flipper/cloud/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def setup_auth(options)
end

def setup_log(options)
set_option :logging_enabled, options, default: true, typecast: :boolean
set_option :logging_enabled, options, default: false, typecast: :boolean
set_option :logger, options, from_env: false, default: -> {
if logging_enabled
Logger.new(STDOUT)
Expand Down Expand Up @@ -214,8 +214,7 @@ def setup_telemetry(options)
Telemetry.instance_for(self)
}

# This is alpha. Don't use this unless you are me. And you are not me.
set_option :telemetry_enabled, options, default: false, typecast: :boolean
set_option :telemetry_enabled, options, default: true, typecast: :boolean
instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
@instrumenter = if telemetry_enabled
Telemetry::Instrumenter.new(self, instrumenter)
Expand Down
12 changes: 4 additions & 8 deletions lib/flipper/cloud/telemetry/instrumenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
module Flipper
module Cloud
class Telemetry
class Instrumenter < SimpleDelegator
class Instrumenter
attr_reader :instrumenter

def initialize(cloud_configuration, instrumenter)
super instrumenter
@instrumenter = instrumenter
@cloud_configuration = cloud_configuration
end

Expand All @@ -14,12 +16,6 @@ def instrument(name, payload = {}, &block)
@cloud_configuration.telemetry.record(name, payload)
return_value
end

private

def instrumenter
__getobj__
end
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/flipper/cloud/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
it "can set instrumenter" do
instrumenter = Object.new
instance = described_class.new(required_options.merge(instrumenter: instrumenter))
expect(instance.instrumenter).to be(instrumenter)
expect(instance.instrumenter).to be_a(Flipper::Cloud::Telemetry::Instrumenter)
expect(instance.instrumenter.instrumenter).to be(instrumenter)
end

it "can set read_timeout" do
Expand Down
6 changes: 4 additions & 2 deletions spec/flipper/cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
expect(client.uri.host).to eq('www.flippercloud.io')
expect(client.uri.path).to eq('/adapter')
expect(client.headers["flipper-cloud-token"]).to eq(token)
expect(@instance.instrumenter).to be(Flipper::Instrumenters::Noop)
expect(@instance.instrumenter).to be_a(Flipper::Cloud::Telemetry::Instrumenter)
expect(@instance.instrumenter.instrumenter).to be(Flipper::Instrumenters::Noop)
end
end

Expand All @@ -62,7 +63,8 @@
it 'can set instrumenter' do
instrumenter = Flipper::Instrumenters::Memory.new
instance = described_class.new(token: 'asdf', instrumenter: instrumenter)
expect(instance.instrumenter).to be(instrumenter)
expect(instance.instrumenter).to be_a(Flipper::Cloud::Telemetry::Instrumenter)
expect(instance.instrumenter.instrumenter).to be(instrumenter)
end

it 'allows wrapping adapter with another adapter like the instrumenter' do
Expand Down
3 changes: 2 additions & 1 deletion spec/flipper/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@
application.initialize!

expect(Flipper.instance).to be_a(Flipper::Cloud::DSL)
expect(Flipper.instance.instrumenter).to be(ActiveSupport::Notifications)
expect(Flipper.instance.instrumenter).to be_a(Flipper::Cloud::Telemetry::Instrumenter)
expect(Flipper.instance.instrumenter.instrumenter).to be(ActiveSupport::Notifications)
end

context "with CLOUD_SYNC_SECRET" do
Expand Down