Commit dec7e2ad authored by Alper Akgun's avatar Alper Akgun Committed by charlie ablett

Add usage ping recording finish times

We want the usage ping to be performant, we'd like to see how long it
takes to calculate the ce and the ee usage data
parent 43b90ae4
---
title: Record usage ping finish time
merge_request: 31222
author:
type: performance
......@@ -38,7 +38,16 @@ module EE
def uncached_data
time_period = { created_at: 28.days.ago..Time.current }
usage_activity_by_stage_monthly = usage_activity_by_stage(:usage_activity_by_stage_monthly, time_period)
super.merge(usage_activity_by_stage).merge(usage_activity_by_stage_monthly)
super
.merge(usage_activity_by_stage)
.merge(usage_activity_by_stage_monthly)
.merge(recording_ee_finish_data)
end
def recording_ee_finish_data
{
recording_ee_finished_at: Time.now
}
end
override :features_usage_data
......
......@@ -673,6 +673,14 @@ describe Gitlab::UsageData do
end
end
describe '.recording_ee_finished_at' do
subject { described_class.recording_ee_finish_data }
it 'gathers time ee recording finishes at' do
expect(subject[:recording_ee_finished_at]).to be_a(Time)
end
end
def for_defined_days_back(days: [29, 2])
days.each do |n|
Timecop.travel(n.days.ago) do
......
......@@ -35,6 +35,7 @@ module Gitlab
.merge(components_usage_data)
.merge(cycle_analytics_usage_data)
.merge(object_store_usage_data)
.merge(recording_ce_finish_data)
end
def to_json(force_refresh: false)
......@@ -43,16 +44,22 @@ module Gitlab
def license_usage_data
{
recorded_at: Time.now, # should be calculated very first
uuid: alt_usage_data { Gitlab::CurrentSettings.uuid },
hostname: alt_usage_data { Gitlab.config.gitlab.host },
version: alt_usage_data { Gitlab::VERSION },
installation_type: alt_usage_data { installation_type },
active_user_count: count(User.active),
recorded_at: Time.now,
edition: 'CE'
}
end
def recording_ce_finish_data
{
recording_ce_finished_at: Time.now
}
end
# rubocop: disable Metrics/AbcSize
# rubocop: disable CodeReuse/ActiveRecord
def system_usage_data
......
......@@ -151,6 +151,14 @@ describe Gitlab::UsageData, :aggregate_failures do
end
end
describe '.recording_ce_finished_at' do
subject { described_class.recording_ce_finish_data }
it 'gathers time ce recording finishes at' do
expect(subject[:recording_ce_finished_at]).to be_a(Time)
end
end
context 'when not relying on database records' do
describe '#features_usage_data_ce' do
subject { described_class.features_usage_data_ce }
......
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