Commit ae9cc6e1 authored by Tetiana Chupryna's avatar Tetiana Chupryna Committed by Douglas Barbosa Alexandre

Add licenses list counter

Calculate backend usage of the feature
parent fe62f194
...@@ -8,6 +8,8 @@ module Projects ...@@ -8,6 +8,8 @@ module Projects
def index def index
respond_to do |format| respond_to do |format|
format.json do format.json do
::Gitlab::UsageDataCounters::LicensesList.count(:views)
render json: serializer.represent(licenses, build: report_service.build) render json: serializer.represent(licenses, build: report_service.build)
end end
end end
......
---
title: Add Licenses list backend usage ping
merge_request: 17925
author:
type: added
...@@ -10,7 +10,7 @@ module EE ...@@ -10,7 +10,7 @@ module EE
override :usage_data_counters override :usage_data_counters
def usage_data_counters def usage_data_counters
super + [::Gitlab::UsageCounters::DesignsCounter] super + [::Gitlab::UsageCounters::DesignsCounter, ::Gitlab::UsageDataCounters::LicensesList]
end end
override :uncached_data override :uncached_data
......
# frozen_string_literal: true
module Gitlab
module UsageDataCounters
class LicensesList < BaseCounter
KNOWN_EVENTS = %w[views].freeze
PREFIX = 'licenses_list'
end
end
end
...@@ -23,6 +23,12 @@ describe Projects::Security::LicensesController do ...@@ -23,6 +23,12 @@ describe Projects::Security::LicensesController do
stub_licensed_features(licenses_list: true, license_management: true) stub_licensed_features(licenses_list: true, license_management: true)
end end
it 'counts usage of the feature' do
expect(::Gitlab::UsageDataCounters::LicensesList).to receive(:count).with(:views)
get_licenses
end
context 'with existing report' do context 'with existing report' do
let!(:pipeline) { create(:ee_ci_pipeline, :with_license_management_report, project: project) } let!(:pipeline) { create(:ee_ci_pipeline, :with_license_management_report, project: project) }
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::UsageDataCounters::LicensesList do
it_behaves_like 'a redis usage counter', 'LicensesList', :views
it_behaves_like 'a redis usage counter with totals', :licenses_list, views: 7
end
...@@ -72,6 +72,7 @@ describe Gitlab::UsageData do ...@@ -72,6 +72,7 @@ describe Gitlab::UsageData do
ldap_keys ldap_keys
ldap_users ldap_users
license_management_jobs license_management_jobs
licenses_list_views
operations_dashboard_default_dashboard operations_dashboard_default_dashboard
operations_dashboard_users_with_projects_added operations_dashboard_users_with_projects_added
pod_logs_usages_total pod_logs_usages_total
......
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