Commit 7e6a6e6b authored by Alper Akgun's avatar Alper Akgun

Merge branch 'mwaw/267550-product_analytics_aggregated_metrics-rollout' into 'master'

[Feature flag] Rollout of: product_analytics_aggregated_metrics

See merge request gitlab-org/gitlab!49886
parents 1e4dbfbc 973a431b
---
title: Add ability to aggregated metrics in Usage Ping
merge_request: 49886
author:
type: added
---
name: product_analytics_aggregated_metrics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44624
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/267550
milestone: '13.6'
type: development
group: group::product analytics
default_enabled: false
......@@ -689,16 +689,12 @@ module Gitlab
end
def aggregated_metrics_monthly
return {} unless Feature.enabled?(:product_analytics_aggregated_metrics)
{
aggregated_metrics: ::Gitlab::UsageDataCounters::HLLRedisCounter.aggregated_metrics_monthly_data
}
end
def aggregated_metrics_weekly
return {} unless Feature.enabled?(:product_analytics_aggregated_metrics)
{
aggregated_metrics: ::Gitlab::UsageDataCounters::HLLRedisCounter.aggregated_metrics_weekly_data
}
......
......@@ -11,7 +11,6 @@
- name: product_analytics_test_metrics_union
operator: OR
events: ['i_search_total', 'i_search_advanced', 'i_search_paid']
feature_flag: product_analytics_aggregated_metrics
- name: product_analytics_test_metrics_intersection
operator: AND
events: ['i_search_total', 'i_search_advanced', 'i_search_paid']
......
......@@ -1255,45 +1255,21 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe 'aggregated_metrics' do
shared_examples 'aggregated_metrics_for_time_range' do
context 'with product_analytics_aggregated_metrics feature flag on' do
before do
stub_feature_flags(product_analytics_aggregated_metrics: true)
end
it 'uses ::Gitlab::UsageDataCounters::HLLRedisCounter#aggregated_metrics_data', :aggregate_failures do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).to receive(aggregated_metrics_data_method).and_return(global_search_gmau: 123)
expect(aggregated_metrics_payload).to eq(aggregated_metrics: { global_search_gmau: 123 })
end
end
context 'with product_analytics_aggregated_metrics feature flag off' do
before do
stub_feature_flags(product_analytics_aggregated_metrics: false)
end
describe '.aggregated_metrics_weekly' do
subject(:aggregated_metrics_payload) { described_class.aggregated_metrics_weekly }
it 'returns empty hash', :aggregate_failures do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(aggregated_metrics_data_method)
expect(aggregated_metrics_payload).to be {}
end
end
end
describe '.aggregated_metrics_weekly' do
subject(:aggregated_metrics_payload) { described_class.aggregated_metrics_weekly }
let(:aggregated_metrics_data_method) { :aggregated_metrics_weekly_data }
it_behaves_like 'aggregated_metrics_for_time_range'
it 'uses ::Gitlab::UsageDataCounters::HLLRedisCounter#aggregated_metrics_data', :aggregate_failures do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:aggregated_metrics_weekly_data).and_return(global_search_gmau: 123)
expect(aggregated_metrics_payload).to eq(aggregated_metrics: { global_search_gmau: 123 })
end
end
describe '.aggregated_metrics_monthly' do
subject(:aggregated_metrics_payload) { described_class.aggregated_metrics_monthly }
let(:aggregated_metrics_data_method) { :aggregated_metrics_monthly_data }
describe '.aggregated_metrics_monthly' do
subject(:aggregated_metrics_payload) { described_class.aggregated_metrics_monthly }
it_behaves_like 'aggregated_metrics_for_time_range'
it 'uses ::Gitlab::UsageDataCounters::HLLRedisCounter#aggregated_metrics_data', :aggregate_failures do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:aggregated_metrics_monthly_data).and_return(global_search_gmau: 123)
expect(aggregated_metrics_payload).to eq(aggregated_metrics: { global_search_gmau: 123 })
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