summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 09:08:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 09:08:14 +0000
commitade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace (patch)
treecf4154332fc95283f58cccb1383e43b40485d91d /app/services
parentba836d98593d68d8d6c22c540e31c8031a786bd8 (diff)
downloadgitlab-ce-ade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/metrics/dashboard/base_service.rb47
1 files changed, 44 insertions, 3 deletions
diff --git a/app/services/metrics/dashboard/base_service.rb b/app/services/metrics/dashboard/base_service.rb
index 3cd7d8437b1..a19f3f78b3d 100644
--- a/app/services/metrics/dashboard/base_service.rb
+++ b/app/services/metrics/dashboard/base_service.rb
@@ -45,9 +45,30 @@ module Metrics
# Returns a new dashboard Hash, supplemented with DB info
def process_dashboard
- ::Gitlab::Metrics::Dashboard::Processor
- .new(project, raw_dashboard, sequence, process_params)
- .process
+ # Get the dashboard from cache/disk before beginning the benchmark.
+ dashboard = raw_dashboard
+ processed_dashboard = nil
+
+ benchmark_processing do
+ processed_dashboard = ::Gitlab::Metrics::Dashboard::Processor
+ .new(project, dashboard, sequence, process_params)
+ .process
+ end
+
+ processed_dashboard
+ end
+
+ def benchmark_processing
+ output = nil
+
+ processing_time_seconds = Benchmark.realtime { output = yield }
+
+ if output
+ processing_time_metric.observe(
+ processing_time_metric_labels,
+ processing_time_seconds * 1_000
+ )
+ end
end
def process_params
@@ -72,6 +93,26 @@ module Metrics
def sequence
SEQUENCE
end
+
+ def processing_time_metric
+ @processing_time_metric ||= ::Gitlab::Metrics.summary(
+ :gitlab_metrics_dashboard_processing_time_ms,
+ 'Metrics dashboard processing time in milliseconds'
+ )
+ end
+
+ def processing_time_metric_labels
+ {
+ stages: sequence_string,
+ service: self.class.name
+ }
+ end
+
+ # If @sequence is [STAGES::CommonMetricsInserter, STAGES::CustomMetricsInserter],
+ # this function will output `CommonMetricsInserter-CustomMetricsInserter`.
+ def sequence_string
+ sequence.map { |stage_class| stage_class.to_s.split('::').last }.join('-')
+ end
end
end
end