Class: Metrics::Dashboard::DynamicEmbedService

Inherits:
BaseEmbedService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/metrics/dashboard/dynamic_embed_service.rb

Direct Known Subclasses

ClusterMetricsEmbedService

Constant Summary

Constants inherited from BaseService

BaseService::SEQUENCE, BaseService::STAGES

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::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseEmbedService

#cache_key, embedded?

Methods inherited from BaseService

all_dashboard_paths, #get_dashboard, out_of_the_box_dashboard?, #raw_dashboard

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

.valid_params?(params) ⇒ Boolean

Determines whether the provided params are sufficient to uniquely identify a panel from a yml-defined dashboard.

See docs.gitlab.com/ee/operations/metrics/dashboards/index.html#defining-custom-dashboards-per-project for additional info on defining custom dashboards.

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
# File 'app/services/metrics/dashboard/dynamic_embed_service.rb', line 23

def valid_params?(params)
  [
    embedded?(params[:embedded]),
    params[:group].present?,
    params[:title].present?,
    params[:y_label]
  ].all?
end

Instance Method Details

#get_raw_dashboardHash

Returns a new dashboard with only the matching metrics from the system dashboard, stripped of groups.

Returns:

  • (Hash)

36
37
38
39
40
# File 'app/services/metrics/dashboard/dynamic_embed_service.rb', line 36

def get_raw_dashboard
  not_found! if panels.empty?

  { 'panel_groups' => [{ 'panels' => panels }] }
end