Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statsd config #779

Merged
merged 1 commit into from
Dec 6, 2023
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
10 changes: 10 additions & 0 deletions lib/flipper/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,15 @@ def default(&block)
@default.call
end
end

def statsd
require 'flipper/instrumentation/statsd_subscriber'
Flipper::Instrumentation::StatsdSubscriber.client
end

def statsd=(client)
require "flipper/instrumentation/statsd"
Flipper::Instrumentation::StatsdSubscriber.client = client
end
end
end
17 changes: 17 additions & 0 deletions spec/flipper/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,21 @@
expect(subject.default).to be(instance)
end
end

describe '#statsd' do
let(:statsd) { double(Statsd) }

after do
Flipper::Instrumentation::StatsdSubscriber.client = nil
end

it 'returns nil by default' do
expect(subject.statsd).to be_nil
end

it 'can be set' do
subject.statsd = statsd
expect(subject.statsd).to be(statsd)
end
end
end
1 change: 0 additions & 1 deletion spec/flipper/instrumentation/statsd_subscriber_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'flipper/adapters/instrumented'
require 'flipper/instrumentation/statsd'
require 'statsd'

begin
require 'active_support/isolated_execution_state'
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Bundler.setup(:default)

require 'debug'
require 'statsd'
require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true)

Expand Down