Class: Metrics::Dashboard::GrafanaMetricEmbedService
- Inherits:
-
BaseEmbedService
- Object
- BaseService
- BaseService
- BaseEmbedService
- Metrics::Dashboard::GrafanaMetricEmbedService
- Includes:
- ReactiveCaching
- Defined in:
- app/services/metrics/dashboard/grafana_metric_embed_service.rb
Constant Summary collapse
- SEQUENCE =
[ ::Gitlab::Metrics::Dashboard::Stages::GrafanaFormatter, ::Gitlab::Metrics::Dashboard::Stages::PanelIdsInserter ].freeze
Constants included from ReactiveCaching
ReactiveCaching::ExceededReactiveCacheLimit, ReactiveCaching::InvalidateReactiveCache, ReactiveCaching::WORK_TYPE
Constants inherited from BaseService
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
- .from_cache(project_id, user_id, grafana_url) ⇒ Object
-
.valid_params?(params) ⇒ Boolean
Determines whether the provided params are sufficient to uniquely identify a grafana dashboard.
Instance Method Summary collapse
- #cache_key(*args) ⇒ Object
-
#calculate_reactive_cache ⇒ Object
Inherits the primary logic from the parent class and maintains the service's API while including ReactiveCache.
- #get_dashboard ⇒ Object
-
#id ⇒ Object
Required for ReactiveCaching; Usage overridden by self.reactive_cache_worker_finder.
Methods inherited from BaseEmbedService
Methods inherited from BaseService
all_dashboard_paths, out_of_the_box_dashboard?, #raw_dashboard
Methods included from Gitlab::Metrics::Dashboard::Errors
#handle_errors, #panels_not_found!
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from BaseService
Class Method Details
.from_cache(project_id, user_id, grafana_url) ⇒ Object
34 35 36 37 38 39 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 34 def from_cache(project_id, user_id, grafana_url) project = Project.find(project_id) user = User.find(user_id) if user_id.present? new(project, user, grafana_url: grafana_url) end |
.valid_params?(params) ⇒ Boolean
Determines whether the provided params are sufficient to uniquely identify a grafana dashboard.
27 28 29 30 31 32 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 27 def valid_params?(params) [ (params[:embedded]), params[:grafana_url] ].all? end |
Instance Method Details
#cache_key(*args) ⇒ Object
58 59 60 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 58 def cache_key(*args) [project.id, current_user&.id, grafana_url] end |
#calculate_reactive_cache ⇒ Object
Inherits the primary logic from the parent class and maintains the service's API while including ReactiveCache
48 49 50 51 52 53 54 55 56 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 48 def calculate_reactive_cache(*) # This is called with explicit parentheses to prevent # the params passed to #calculate_reactive_cache from # being passed to #get_dashboard (which accepts none) ::Metrics::Dashboard::BaseService .instance_method(:get_dashboard) .bind(self) .call() # rubocop:disable Style/MethodCallWithoutArgsParentheses end |
#get_dashboard ⇒ Object
42 43 44 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 42 def get_dashboard with_reactive_cache(*cache_key) { |result| result } end |
#id ⇒ Object
Required for ReactiveCaching; Usage overridden by self.reactive_cache_worker_finder
64 65 66 |
# File 'app/services/metrics/dashboard/grafana_metric_embed_service.rb', line 64 def id nil end |