Commit 4fec016f authored by Michael Kozono's avatar Michael Kozono

Merge branch '218649-change-finder' into 'master'

Update metrics dashboard finder to list all predefined dashboards

See merge request gitlab-org/gitlab!35768
parents 839c36a6 b9a2ddb0
......@@ -7,6 +7,19 @@ module Gitlab
module Metrics
module Dashboard
class Finder
# Dashboards that should not be part of the list of all dashboards
# displayed on the metrics dashboard page.
PREDEFINED_DASHBOARD_EXCLUSION_LIST = [
# This dashboard is only useful in the self monitoring project.
::Metrics::Dashboard::SelfMonitoringDashboardService,
# This dashboard is displayed on the K8s cluster settings health page.
::Metrics::Dashboard::ClusterDashboardService,
# This dashboard is not yet ready for the world.
::Metrics::Dashboard::PodDashboardService
].freeze
class << self
# Returns a formatted dashboard packed with DB info.
# @param project [Project]
......@@ -67,12 +80,32 @@ module Gitlab
def find_all_paths_from_source(project)
Gitlab::Metrics::Dashboard::Cache.delete_all!
default_dashboard_path(project)
.+ project_service.all_dashboard_paths(project)
user_facing_dashboard_services(project).flat_map do |service|
service.all_dashboard_paths(project)
end
end
private
def user_facing_dashboard_services(project)
predefined_dashboard_services_for(project) + [project_service]
end
def predefined_dashboard_services_for(project)
# Only list the self monitoring dashboard on the self monitoring project,
# since it is the only dashboard (at time of writing) that shows data
# about GitLab itself.
if project.self_monitoring?
return [self_monitoring_service]
end
predefined_dashboard_services
end
def predefined_dashboard_services
::Metrics::Dashboard::PredefinedDashboardService.descendants - PREDEFINED_DASHBOARD_EXCLUSION_LIST
end
def system_service
::Metrics::Dashboard::SystemDashboardService
end
......@@ -85,14 +118,6 @@ module Gitlab
::Metrics::Dashboard::SelfMonitoringDashboardService
end
def default_dashboard_path(project)
if project.self_monitoring?
self_monitoring_service.all_dashboard_paths(project)
else
system_service.all_dashboard_paths(project)
end
end
def service_for(options)
Gitlab::Metrics::Dashboard::ServiceSelector.call(options)
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