lib/skylight/messages/trace.rb in skylight-0.1.4.alpha2 vs lib/skylight/messages/trace.rb in skylight-0.1.4.alpha3
- old
+ new
@@ -67,11 +67,11 @@
end
def record(time, cat, title = nil, desc = nil, annot = {})
return if @busted
- track_time(time)
+ time = adjust_for_skew(time)
sp = span(time, cat, title, desc, annot)
return self if :skip == sp
@@ -82,11 +82,11 @@
end
def start(time, cat, title = nil, desc = nil, annot = {})
return if @busted
- track_time(time)
+ time = adjust_for_skew(time)
sp = span(time, cat, title, desc, annot)
push(sp)
@@ -94,11 +94,11 @@
end
def stop(time)
return if @busted
- track_time(time)
+ time = adjust_for_skew(time)
sp = pop
return self if :skip == sp
@@ -184,18 +184,18 @@
else
((time - @start) / 100).to_i
end
end
- def track_time(time)
- if time < @last_seen_time
- @busted = true
- raise TraceError, "time moving backwards; " \
- "prev=#{@last_seen_time}; " \
- "curr=#{time}"
+ # Sadely, we don't have access to a pure monotonic clock in ruby, so we
+ # need to cheat a little.
+ def adjust_for_skew(time)
+ if time <= @last_seen_time
+ return @last_seen_time
end
@last_seen_time = time
+ time
end
end
end