blob: b455f95537726f7bc86c615529e84e42f6873fce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
# Responsible for determining which dashboard service should
# be used to fetch or generate a dashboard hash.
# The services can be considered in two categories - embeds
# and dashboards. Embed hashes are identical to dashboard hashes except
# that they contain a subset of panels.
module Gitlab
module Metrics
module Dashboard
class ServiceSelector
class << self
include Gitlab::Utils::StrongMemoize
SERVICES = [
::Metrics::Dashboard::GitlabAlertEmbedService,
::Metrics::Dashboard::CustomMetricEmbedService,
::Metrics::Dashboard::GrafanaMetricEmbedService,
::Metrics::Dashboard::DynamicEmbedService,
::Metrics::Dashboard::DefaultEmbedService,
::Metrics::Dashboard::SystemDashboardService,
::Metrics::Dashboard::PodDashboardService,
::Metrics::Dashboard::SelfMonitoringDashboardService,
::Metrics::Dashboard::CustomDashboardService
].freeze
# Returns a class which inherits from the BaseService
# class that can be used to obtain a dashboard for
# the provided params.
# @return [Gitlab::Metrics::Dashboard::Services::BaseService]
def call(params)
service = services.find do |service_class|
service_class.valid_params?(params)
end
service || default_service
end
private
def services
SERVICES
end
def default_service
::Metrics::Dashboard::SystemDashboardService
end
end
end
end
end
end
Gitlab::Metrics::Dashboard::ServiceSelector.prepend_if_ee('EE::Gitlab::Metrics::Dashboard::ServiceSelector')
|