Commit c7fc7839 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '224602-optimize-usage-ping-metrics-based-on-issues-table' into 'master'

Use memoized start/finish for metrics based on issues table

Closes #224602

See merge request gitlab-org/gitlab!37155
parents dce12105 9fc7fa72
---
title: Use memoized start/finish for metrics based on issues table
merge_request: 37155
author:
type: performance
...@@ -115,7 +115,9 @@ module EE ...@@ -115,7 +115,9 @@ module EE
project: projects_with_service_desk, project: projects_with_service_desk,
author: ::User.support_bot, author: ::User.support_bot,
confidential: true confidential: true
) ),
start: issue_minimum_id,
finish: issue_maximum_id
) )
} }
end end
...@@ -189,7 +191,7 @@ module EE ...@@ -189,7 +191,7 @@ module EE
projects_with_packages: distinct_count(::Packages::Package, :project_id), projects_with_packages: distinct_count(::Packages::Package, :project_id),
projects_with_tracing_enabled: count(ProjectTracingSetting), projects_with_tracing_enabled: count(ProjectTracingSetting),
status_page_projects: count(::StatusPage::ProjectSetting.enabled), status_page_projects: count(::StatusPage::ProjectSetting.enabled),
status_page_issues: count(::Issue.on_status_page), status_page_issues: count(::Issue.on_status_page, start: issue_minimum_id, finish: issue_maximum_id),
template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates) template_repositories: count(::Project.with_repos_templates) + count(::Project.with_groups_level_repos_templates)
}, },
requirements_counts, requirements_counts,
......
...@@ -66,8 +66,8 @@ module Gitlab ...@@ -66,8 +66,8 @@ module Gitlab
# rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/AbcSize
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def system_usage_data def system_usage_data
alert_bot_incident_count = count(::Issue.authored(::User.alert_bot)) alert_bot_incident_count = count(::Issue.authored(::User.alert_bot), start: issue_minimum_id, finish: issue_maximum_id)
issues_created_manually_from_alerts = count(Issue.with_alert_management_alerts.not_authored_by(::User.alert_bot)) issues_created_manually_from_alerts = count(Issue.with_alert_management_alerts.not_authored_by(::User.alert_bot), start: issue_minimum_id, finish: issue_maximum_id)
{ {
counts: { counts: {
...@@ -114,7 +114,7 @@ module Gitlab ...@@ -114,7 +114,7 @@ module Gitlab
in_review_folder: count(::Environment.in_review_folder), in_review_folder: count(::Environment.in_review_folder),
grafana_integrated_projects: count(GrafanaIntegration.enabled), grafana_integrated_projects: count(GrafanaIntegration.enabled),
groups: count(Group), groups: count(Group),
issues: count(Issue), issues: count(Issue, start: issue_minimum_id, finish: issue_maximum_id),
issues_created_from_gitlab_error_tracking_ui: count(SentryIssue), issues_created_from_gitlab_error_tracking_ui: count(SentryIssue),
issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue), issues_with_associated_zoom_link: count(ZoomMeeting.added_to_issue),
issues_using_zoom_quick_actions: distinct_count(ZoomMeeting, :issue_id), issues_using_zoom_quick_actions: distinct_count(ZoomMeeting, :issue_id),
...@@ -124,7 +124,7 @@ module Gitlab ...@@ -124,7 +124,7 @@ module Gitlab
issues_created_manually_from_alerts: issues_created_manually_from_alerts, issues_created_manually_from_alerts: issues_created_manually_from_alerts,
incident_issues: alert_bot_incident_count, incident_issues: alert_bot_incident_count,
alert_bot_incident_issues: alert_bot_incident_count, alert_bot_incident_issues: alert_bot_incident_count,
incident_labeled_issues: count(::Issue.with_label_attributes(::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES)), incident_labeled_issues: count(::Issue.with_label_attributes(::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES), start: issue_minimum_id, finish: issue_maximum_id),
keys: count(Key), keys: count(Key),
label_lists: count(List.label), label_lists: count(List.label),
lfs_objects: count(LfsObject), lfs_objects: count(LfsObject),
...@@ -630,9 +630,9 @@ module Gitlab ...@@ -630,9 +630,9 @@ module Gitlab
# Remove prometheus table queries once they are deprecated # Remove prometheus table queries once they are deprecated
# To be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/217407. # To be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/217407.
[ [
count(Issue.with_alert_management_alerts), count(Issue.with_alert_management_alerts, start: issue_minimum_id, finish: issue_maximum_id),
count(::Issue.with_self_managed_prometheus_alert_events), count(::Issue.with_self_managed_prometheus_alert_events, start: issue_minimum_id, finish: issue_maximum_id),
count(::Issue.with_prometheus_alert_events) count(::Issue.with_prometheus_alert_events, start: issue_minimum_id, finish: issue_maximum_id)
].reduce(:+) ].reduce(:+)
end 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