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 ...@@ -7,6 +7,19 @@ module Gitlab
module Metrics module Metrics
module Dashboard module Dashboard
class Finder 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 class << self
# Returns a formatted dashboard packed with DB info. # Returns a formatted dashboard packed with DB info.
# @param project [Project] # @param project [Project]
...@@ -67,12 +80,32 @@ module Gitlab ...@@ -67,12 +80,32 @@ module Gitlab
def find_all_paths_from_source(project) def find_all_paths_from_source(project)
Gitlab::Metrics::Dashboard::Cache.delete_all! Gitlab::Metrics::Dashboard::Cache.delete_all!
default_dashboard_path(project) user_facing_dashboard_services(project).flat_map do |service|
.+ project_service.all_dashboard_paths(project) service.all_dashboard_paths(project)
end
end end
private 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 def system_service
::Metrics::Dashboard::SystemDashboardService ::Metrics::Dashboard::SystemDashboardService
end end
...@@ -85,14 +118,6 @@ module Gitlab ...@@ -85,14 +118,6 @@ module Gitlab
::Metrics::Dashboard::SelfMonitoringDashboardService ::Metrics::Dashboard::SelfMonitoringDashboardService
end 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) def service_for(options)
Gitlab::Metrics::Dashboard::ServiceSelector.call(options) Gitlab::Metrics::Dashboard::ServiceSelector.call(options)
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