Commit 9029fc57 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '276948-remove-feature-check-from-utils-usage-data' into 'master'

Remove extra feature check from utils usage_data.rb [RUN ALL RSPEC][RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!54208
parents 2dc5ffc1 84dad215
......@@ -165,6 +165,7 @@
redis_slot: source_code
category: source_code
aggregation: daily
feature_flag: usage_data_i_source_code_code_intelligence
# Incident management
- name: incident_management_alert_status_changed
redis_slot: incident_management
......
......@@ -135,8 +135,6 @@ module Gitlab
# @param event_name [String] the event name
# @param values [Array|String] the values counted
def track_usage_event(event_name, values)
return unless Feature.enabled?(:"usage_data_#{event_name}", default_enabled: true)
Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name.to_s, values: values)
end
......
......@@ -362,38 +362,15 @@ RSpec.describe Gitlab::Utils::UsageData do
let(:value) { '9f302fea-f828-4ca9-aef4-e10bd723c0b3' }
let(:event_name) { 'incident_management_alert_status_changed' }
let(:unknown_event) { 'unknown' }
let(:feature) { "usage_data_#{event_name}" }
before do
skip_feature_flags_yaml_validation
end
context 'with feature enabled' do
before do
stub_feature_flags(feature => true)
end
it 'tracks redis hll event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: value)
described_class.track_usage_event(event_name, value)
end
it 'tracks redis hll event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(event_name, values: value)
it 'raise an error for unknown event' do
expect { described_class.track_usage_event(unknown_event, value) }.to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownEvent)
end
described_class.track_usage_event(event_name, value)
end
context 'with feature disabled' do
before do
stub_feature_flags(feature => false)
end
it 'does not track event' do
expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
described_class.track_usage_event(event_name, value)
end
it 'raise an error for unknown event' do
expect { described_class.track_usage_event(unknown_event, value) }.to raise_error(Gitlab::UsageDataCounters::HLLRedisCounter::UnknownEvent)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment