blob: 3e7026b8dea4a3df1f58a49e3868b8faebae4cc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
module Gitlab
module Metrics
class BootTimeTracker
include Singleton
SUPPORTED_RUNTIMES = [:puma, :sidekiq, :console].freeze
def startup_time
@startup_time || 0
end
def track_boot_time!(logger: Gitlab::AppJsonLogger)
return if @startup_time
runtime = Gitlab::Runtime.safe_identify
return unless SUPPORTED_RUNTIMES.include?(runtime)
@startup_time = Gitlab::Metrics::System.process_runtime_elapsed_seconds
Gitlab::Metrics.gauge(
:gitlab_rails_boot_time_seconds, 'Time elapsed for Rails primary process to finish startup'
).set({}, @startup_time)
logger.info(message: 'Application boot finished', runtime: runtime.to_s, duration_s: @startup_time)
end
def reset!
@startup_time = nil
end
end
end
end
|