Class: Metrics::Dashboard::CustomMetricEmbedService

Inherits:
BaseEmbedService show all
Extended by:
Gitlab::Utils::Override
Includes:
Gitlab::Metrics::Dashboard::Defaults, Gitlab::Utils::StrongMemoize
Defined in:
app/services/metrics/dashboard/custom_metric_embed_service.rb

Constant Summary

Constants included from Gitlab::Metrics::Dashboard::Defaults

Gitlab::Metrics::Dashboard::Defaults::DEFAULT_PANEL_TYPE

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::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

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?

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 composed of user-defined custom metrics from the DB.

Returns:

  • (Boolean)

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

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

Instance Method Details

#raw_dashboardHash

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

Note: This overrides the method #raw_dashboard, which means the result will not be cached. This is because we are inserting DB info into the dashboard before post-processing. This ensures we aren't acting on deleted or out-of-date metrics.

Returns:

  • (Hash)

58
# File 'app/services/metrics/dashboard/custom_metric_embed_service.rb', line 58

override :raw_dashboard