Commit 38cca778 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'am-use-only-data-usage_data-method' into 'master'

Make Gitlab::UsageData.uncached_data private

See merge request gitlab-org/gitlab!79198
parents 2969055a fadc6629
......@@ -53,13 +53,6 @@ module EE
class_methods do
extend ::Gitlab::Utils::Override
override :uncached_data
def uncached_data
with_finished_at(:recording_ee_finished_at) do
super
end
end
override :features_usage_data
def features_usage_data
super.merge(features_usage_data_ee)
......@@ -401,6 +394,13 @@ module EE
private
override :uncached_data
def uncached_data
with_finished_at(:recording_ee_finished_at) do
super
end
end
# rubocop:disable CodeReuse/ActiveRecord
# rubocop: disable UsageData/LargeTable
def count_secure_scans(time_period)
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe 'Every metric definition' do
include UsageDataHelpers
let(:usage_ping) { Gitlab::UsageData.uncached_data }
let(:usage_ping) { Gitlab::UsageData.data(force_refresh: true) }
let(:ignored_usage_ping_key_patterns) do
%w(
license_add_ons
......
......@@ -10,10 +10,10 @@ RSpec.describe Gitlab::UsageDataNonSqlMetrics do
stub_database_flavor_check
end
describe '.uncached_data' do
describe '.data' do
it 'does make instrumentations_class DB calls' do
recorder = ActiveRecord::QueryRecorder.new do
described_class.uncached_data
described_class.data(force_refresh: true)
end
expect(recorder.count).to eq(65)
......
......@@ -801,7 +801,7 @@ RSpec.describe Gitlab::UsageData do
it 'clears memoized values' do
allow(described_class).to receive(:clear_memoization)
described_class.uncached_data
described_class.data(force_refresh: true)
described_class::EE_MEMOIZED_VALUES.each do |key|
expect(described_class).to have_received(:clear_memoization).with(key)
......
......@@ -18,7 +18,7 @@ module API
get 'non_sql_metrics' do
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/325534')
data = Gitlab::UsageDataNonSqlMetrics.uncached_data
data = Gitlab::UsageDataNonSqlMetrics.data(force_refresh: true)
present data
end
......
......@@ -18,7 +18,7 @@ module API
get 'queries' do
Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/325534')
queries = Gitlab::UsageDataQueries.uncached_data
queries = Gitlab::UsageDataQueries.data(force_refresh: true)
present queries
end
......
......@@ -47,14 +47,6 @@ module Gitlab
end
end
def uncached_data
clear_memoized
with_finished_at(:recording_ce_finished_at) do
usage_data_metrics
end
end
def to_json(force_refresh: false)
data(force_refresh: force_refresh).to_json
end
......@@ -697,6 +689,14 @@ module Gitlab
private
def uncached_data
clear_memoized
with_finished_at(:recording_ce_finished_at) do
usage_data_metrics
end
end
def stage_manage_events(time_period)
if time_period.empty?
Gitlab::Utils::UsageData::FALLBACK
......
......@@ -4,17 +4,17 @@ namespace :gitlab do
namespace :usage_data do
desc 'GitLab | UsageData | Generate raw SQLs for usage ping in YAML'
task dump_sql_in_yaml: :environment do
puts Gitlab::UsageDataQueries.uncached_data.to_yaml
puts Gitlab::UsageDataQueries.data(force_refresh: true).to_yaml
end
desc 'GitLab | UsageData | Generate raw SQLs for usage ping in JSON'
task dump_sql_in_json: :environment do
puts Gitlab::Json.pretty_generate(Gitlab::UsageDataQueries.uncached_data)
puts Gitlab::Json.pretty_generate(Gitlab::UsageDataQueries.data(force_refresh: true))
end
desc 'GitLab | UsageData | Generate usage ping in JSON'
task generate: :environment do
puts Gitlab::Json.pretty_generate(Gitlab::UsageData.uncached_data)
puts Gitlab::Json.pretty_generate(Gitlab::UsageData.data(force: true))
end
desc 'GitLab | UsageData | Generate usage ping and send it to Versions Application'
......
......@@ -12,8 +12,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
stub_database_flavor_check('Cloud SQL for PostgreSQL')
end
describe '.uncached_data' do
subject { described_class.uncached_data }
describe '.data' do
subject { described_class.data(force_refresh: true) }
it 'includes basic top and second level keys' do
is_expected.to include(:counts)
......
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