-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging events and dealing with clock drift #198
Comments
@rmarx asked me to explain this further or more clearly. So lets try a different angle. Here is what qlog says
Each event has a timestamp, whose value is calculated according to the format. qlog hints that the UNIX epoch is "typical", which leaves the door open to other epoch. But qlog doesn't really support expressing what the epoch is explicitly. The
If wishing to not use the unix epoch as the relative format's epoch, the spec if not clear how to represent that. A common producer use case is to want to log events starting with a timestamp of 0, and then to progress forward in ascending time durations. For this use case, the reference_time field does not add much value. Setting a An implied reference clock based on e.g. the unix clock, sets up other caveats. In some environments, it is possible to operate in abstract time durations, where the epoch cannot be serialized to a value that makes sense for any other system. For example, Rust provides an Instant type against which monotonic time durations can be calculated. The alternative would be to use SystemTime time, where durations do not have the same guarantee due the possibility of clocks being moved forward or backwards; see https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.duration_since Finally, qlog recommends
While it alludes to some of the problems of time-synchronization, it could probably be clearer. This is especially true if using a relative time format based on a wall clock reference where clock changes could cause a negative value to be logged in the timestamp. Naively sorting these logs based on the relative timestamp would produce an incorrect view of the connection's events. Instead, a tool trying to do some log consolidation and sorting needs to be very date-time aware. That probably extends to qlog consumers, for example, if they convert to a human-friendly representation then it should not be unexpected that clocks go backward or forward. |
We had a question about quiche's logging on cloudflare/quiche#1197 this got me thinking some more about representations of time in qlog.
In quiche, we use a monotonic non-decreasing clock. When a trace is started, we store a monotonic start time internally and don't put that in the qlog. As events are created, we calculate a relative time since the start and record that.
I've now realised this behaviour seems to differ from what the qlog draft states in https://quicwg.org/qlog/draft-ietf-quic-qlog-main-schema.html#name-timestamps
The problem is that clock drift can occur. The spec mentions this briefly but I wonder if the problem is larger than people give consideration to. For the relative and base time formats, you'd potentially end up smaller or negative values, which might break qlog tooling.
I don't have much insight into solving clock drift problems but could we consider adding a monotonic time format type in addition?
The text was updated successfully, but these errors were encountered: