Skip to content

Commit

Permalink
Fixes #36841 - Switch to Process.clock_gettime for ping
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Oct 19, 2023
1 parent 2ae0516 commit 66f0c87
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/services/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def statuses
private

def duration_ms(start)
((Time.new - start) * 1000).round.to_s
(current_time - start).to_s
end

def ping_database
start = Time.now
start = current_time
{
active: ActiveRecord::Base.connection.active?,
duration_ms: duration_ms(start),
Expand All @@ -50,7 +50,7 @@ def ping_database
def statuses_compute_resources
results = []
ComputeResource.all.index.map do |resource|
start = Time.now
start = current_time
errors = resource.ping
results << {
name: resource.name,
Expand All @@ -65,7 +65,7 @@ def statuses_compute_resources
def statuses_smart_proxies
results = []
SmartProxy.all.includes(:features).map do |proxy|
start = Time.now
start = current_time
begin
version = proxy.statuses[:version].version['version']
features = proxy.statuses[:version].version['modules']
Expand Down Expand Up @@ -102,5 +102,9 @@ def plugins_statuses
all.update({ "#{plugin.name}": plugin.status_extension.call })
end
end

def current_time
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
end
end
end

0 comments on commit 66f0c87

Please sign in to comment.