Commit 407a946f authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'kassio/add-project-imports-total-metric' into 'master'

Importer Metrics: Add the total number of projects imported

See merge request gitlab-org/gitlab!61775
parents 0fc3ec38 f8e584e9
---
title: Add metrics to calculate rate of project imports
merge_request: 61775
author:
type: added
---
key_path: usage_activity_by_stage_monthly.manage.project_imports.gitlab
description: ''
description: Count of projects imported from GitLab using Project Export/Import
product_section: dev
product_stage: manage
product_group: group::import
......
---
key_path: counts_monthly.projects
description: 'Count number of projects created monthly'
product_section: dev
product_stage: plan
product_group: group::project management
product_category: ''
value_type: number
status: implemented
milestone: "14.0"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61775
time_frame: 28d
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: usage_activity_by_stage_monthly.manage.project_imports.total
description: Total count of projects imported
product_section: dev
product_stage: manage
product_group: group::import
product_category:
value_type: number
status: implemented
milestone: "14.0"
introduced_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61775"
time_frame: 28d
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: usage_activity_by_stage.manage.project_imports.total
description: 'Count number of projects imported monthly'
product_section: dev
product_stage: manage
product_group: group::import
product_category:
value_type: number
status: implemented
milestone: "14.0"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61775
time_frame: all
data_source: database
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -6718,6 +6718,18 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts_monthly.projects`
Count number of projects created monthly
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210514141518_monthly_projects_creation.yml)
Group: `group::project management`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts_monthly.projects_with_alerts_created`
Monthly count of unique projects with HTTP alerting enabled
......@@ -16548,6 +16560,18 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `usage_activity_by_stage.manage.project_imports.total`
Count number of projects imported monthly
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210514141520_project_imports_total.yml)
Group: `group::import`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `usage_activity_by_stage.manage.projects_imported.bitbucket`
Distinct count of users that imported projects from Bitbucket Cloud
......@@ -18460,7 +18484,7 @@ Tiers: `free`, `premium`, `ultimate`
### `usage_activity_by_stage_monthly.manage.project_imports.gitlab`
Missing description
Count of projects imported from GitLab using Project Export/Import
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210216183646_gitlab.yml)
......@@ -18506,6 +18530,18 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `usage_activity_by_stage_monthly.manage.project_imports.total`
Total count of projects imported
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210520111133_total.yml)
Group: `group::import`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `usage_activity_by_stage_monthly.manage.projects_imported.bitbucket`
Count of projects imported from Bitbucket
......
......@@ -232,6 +232,7 @@ module Gitlab
successful_deployments: deployment_count(Deployment.success.where(last_28_days_time_period)),
failed_deployments: deployment_count(Deployment.failed.where(last_28_days_time_period)),
# rubocop: enable UsageData/LargeTable:
projects: count(Project.where(last_28_days_time_period), start: minimum_id(Project), finish: maximum_id(Project)),
packages: count(::Packages::Package.where(last_28_days_time_period)),
personal_snippets: count(PersonalSnippet.where(last_28_days_time_period)),
project_snippets: count(ProjectSnippet.where(last_28_days_time_period)),
......@@ -916,7 +917,7 @@ module Gitlab
end
def project_imports(time_period)
{
counters = {
gitlab_project: projects_imported_count('gitlab_project', time_period),
gitlab: projects_imported_count('gitlab', time_period),
github: projects_imported_count('github', time_period),
......@@ -927,6 +928,10 @@ module Gitlab
manifest: projects_imported_count('manifest', time_period),
gitlab_migration: count(::BulkImports::Entity.where(time_period).project_entity) # rubocop: disable CodeReuse/ActiveRecord
}
counters[:total] = add(*counters.values)
counters
end
def projects_imported_count(from, time_period)
......
......@@ -294,7 +294,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
gitlab: 2,
gitlab_migration: 2,
gitlab_project: 2,
manifest: 2
manifest: 2,
total: 18
},
issue_imports: {
jira: 2,
......@@ -341,7 +342,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
gitlab: 1,
gitlab_migration: 1,
gitlab_project: 1,
manifest: 1
manifest: 1,
total: 9
},
issue_imports: {
jira: 1,
......@@ -371,7 +373,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
csv: Gitlab::UsageData::DEPRECATED_VALUE
},
groups_imported: Gitlab::UsageData::DEPRECATED_VALUE
}
)
end
......@@ -706,10 +707,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
describe '.system_usage_data_monthly' do
let_it_be(:project) { create(:project) }
let_it_be(:project) { create(:project, created_at: 3.days.ago) }
before do
project = create(:project)
env = create(:environment)
create(:package, project: project, created_at: 3.days.ago)
create(:package, created_at: 2.months.ago, project: project)
......@@ -742,6 +742,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(counts_monthly[:personal_snippets]).to eq(1)
expect(counts_monthly[:project_snippets]).to eq(1)
expect(counts_monthly[:projects_with_alerts_created]).to eq(1)
expect(counts_monthly[:projects]).to eq(1)
expect(counts_monthly[:packages]).to eq(1)
expect(counts_monthly[:promoted_issues]).to eq(1)
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