Add collected_data_categories to usage ping payload
Requirements
-
Add a new metric to indicate what data types we send in JSON payload
Add
Standard
metriccollected_data_categories
to usage ping payload.The values we set in this metric should be aligned and reflect the data sent to VersionsApp
-
Add examples of payloads to issue https://gitlab.com/gitlab-data/analytics/-/issues/9384 for data team.
Scenarios
Scenario 1
For free users when there is no license License.current.present? == false
and usage ping enabled
collected_data_categories: [Standard, Subscription, Optional, Operational]
Scenario 2
For free users when there is no license License.current.present? == false
and usage ping disabled we don't send any data
Scenario 3
For a customer when there is a license License.current.present? == true
. With usage ping enabled and operational data enabled(License.current.usage_ping? == true
)
collected_data_categories: [Standard, Subscription, Optional, Operational]
Scenario 4
For a customer when there is a license License.current.present? == true
. With usage ping disabled and operational data enabled(License.current.usage_ping? == true
)
collected_data_categories: [Standard, Subscription, Operational]
Scenario 5
For a customer when there is a license License.current.present? == true
. With usage ping enabled and operational data diabled(License.current.usage_ping? == false
)
collected_data_categories: [Standard, Subscription, Optional]
Scenario 6
For a customer when there is a license License.current.present? == true
. With usage ping disabled and operational data disabled(License.current.usage_ping? == false
) we don't send any data
Implementation proposal
This can be added as a Generic instrumentation class.
module Gitlab
module Usage
module Metrics
class CollectedDataCategoriesMetric < GenericMetric
# # This could be done probably in a better way
value do
if License.current.present?
if Gitlab::CurrentSettings.usage_ping_enabled? && License.current.usage_ping?
select_metrics(data_type: ['Standard', 'Subscription', 'Operational', 'Optional'])
elsif Gitlab::CurrentSettings.usage_ping_enabled?
select_metrics(data_type: ['Standard', `Subscription`, 'Optional'])
elsif License.current.usage_ping?
select_metrics(data_type: ['Standard', 'Subscription', 'Operational'])
end
else
if Gitlab::CurrentSettings.usage_ping_enabled?
select_metrics(data_type: ['Standard', 'Subscription', 'Operational', 'Optional'])
end
end
end
end
end
end
# later in usage_data.rb
collected_data_categories: Gitlab::Usage::Metrics::Instrumentations::CollectedDataCategoriesMetric.new(time_frame: 'none').value