Class: Metrics::Dashboard::BaseService

Inherits:
BaseService show all
Includes:
Gitlab::Metrics::Dashboard::Errors
Defined in:
app/services/metrics/dashboard/base_service.rb

Constant Summary collapse

STAGES =
::Gitlab::Metrics::Dashboard::Stages
SEQUENCE =
[
  STAGES::CommonMetricsInserter,
  STAGES::MetricEndpointInserter,
  STAGES::VariableEndpointInserter,
  STAGES::PanelIdsInserter,
  STAGES::TrackPanelType,
  STAGES::AlertsInserter,
  STAGES::UrlValidator
].freeze

Constants included from Gitlab::Metrics::Dashboard::Errors

Gitlab::Metrics::Dashboard::Errors::DashboardProcessingError, Gitlab::Metrics::Dashboard::Errors::LayoutError, Gitlab::Metrics::Dashboard::Errors::MissingIntegrationError, Gitlab::Metrics::Dashboard::Errors::MissingQueryError, Gitlab::Metrics::Dashboard::Errors::NOT_FOUND_ERROR, Gitlab::Metrics::Dashboard::Errors::PanelNotFoundError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Metrics::Dashboard::Errors

#handle_errors, #panels_not_found!

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Class Method Details

.all_dashboard_paths(_project) ⇒ Array<Hash>

Summary of all known dashboards for the service.

Returns:

  • (Array<Hash>)

    ex) [{ path: String, default: Boolean }]

Raises:

  • (NotImplementedError)

31
32
33
# File 'app/services/metrics/dashboard/base_service.rb', line 31

def self.all_dashboard_paths(_project)
  raise NotImplementedError
end

.out_of_the_box_dashboard?Boolean

Should return true if this dashboard service is for an out-of-the-box dashboard. This method is overridden in app/services/metrics/dashboard/predefined_dashboard_service.rb.

Returns:

  • (Boolean)

    Boolean


44
45
46
# File 'app/services/metrics/dashboard/base_service.rb', line 44

def self.out_of_the_box_dashboard?
  false
end

Instance Method Details

#get_dashboardObject


21
22
23
24
25
26
27
# File 'app/services/metrics/dashboard/base_service.rb', line 21

def get_dashboard
  return error('Insufficient permissions.', :unauthorized) unless allowed?

  success(dashboard: process_dashboard)
rescue StandardError => e
  handle_errors(e)
end

#raw_dashboardObject

Returns an un-processed dashboard from the cache.


36
37
38
# File 'app/services/metrics/dashboard/base_service.rb', line 36

def raw_dashboard
  Gitlab::Metrics::Dashboard::Cache.for(project).fetch(cache_key) { get_raw_dashboard }
end