Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clarifying latency logging by adding units and removing timer latency…

… itself
  • Loading branch information...
commit 586d36516764af3435fbedc0e4f6c7d80fd2c99a 1 parent 11c996b
Travis Truman trumant authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/goliath/plugins/latency.rb
10 lib/goliath/plugins/latency.rb
View
@@ -6,6 +6,10 @@ module Plugin
# plugin Goliath::Plugin::Latency
#
class Latency
+
+ # Number of seconds to wait before logging latency
+ LATENCY_TIMING = 1
+
# Called by the framework to initialize the plugin
#
# @param port [Integer] Unused
@@ -28,9 +32,9 @@ def self.recent_latency
# Called automatically to start the plugin
def run
- EM.add_periodic_timer(1) do
- @@recent_latency = (Time.now.to_f - @last)
- @logger.info "LATENCY: #{@@recent_latency}"
+ EM.add_periodic_timer(LATENCY_TIMING) do
+ @@recent_latency = ((Time.now.to_f - @last) - LATENCY_TIMING)
+ @logger.info "LATENCY: #{(@@recent_latency * 1000)} ms"
@last = Time.now.to_f
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.