Time and sequence of events
The timeline puts each event at one time. This page explains which time that is.
Event time and arrival time
Section titled “Event time and arrival time”An event can have two times:
- The event time is the
timefield. The producer or the broker sets it. - The arrival time is the time when streamview gets the event.
streamview uses the event time. If an event has no time field, streamview uses the arrival time.
The event time shows when something occurred in your system. This is important when streamview reads old messages. With the arrival time, all old messages would be at the start time of streamview.
The adapters set the event time from the broker:
| Message | Event time |
|---|---|
| Kafka message | The timestamp of the message. |
| NATS message from a stream | The time when the stream stored the message. |
| Other NATS message | The arrival time. A NATS message has no time of its own. |
| RabbitMQ message | The arrival time. streamview gets each message a moment after a program publishes it. |
Old messages
Section titled “Old messages”A broker does not give old messages in time sequence. Kafka gives the old messages of one partition, and then of the next partition. NATS gives each stream separately.
Thus the adapters hold the old messages until they have all of them. Then they sort the messages by time, and send them to the server. After that, they send each new message immediately.
This is the cause of the delay at the start. With many stored messages, the page stays empty for some minutes.
Events that are a small time apart
Section titled “Events that are a small time apart”New events also do not arrive in exact time sequence. The server holds each event for 1.5 seconds, and releases the events in time sequence.
Thus the timeline is approximately 1.5 seconds behind the newest event.
Late events
Section titled “Late events”A late event has an event time that is earlier than an event that the server already released. The engine keeps events in time sequence, and cannot put an event in the past.
The server puts a late event at the time of the last released event.
The event panel shows the JSON with the original time field.
GET /api/stats gives the number of late events.
For the same reason, an archive of old events needs a store of its own. In a store that already has newer events, all events of the archive are late.
A file is possibly not in time sequence. Then streamview serve --sort holds all events until the end of the file, and releases them in time sequence.
Events from the future
Section titled “Events from the future”An event can have a time that is after the current time. A small difference is usual, because clocks are not equal. A large difference is an error in the event.
If the time of an event is more than 5 minutes after the current time, the server uses the arrival time. Without this rule, one event with a time in a later year would make all subsequent events late. The server would then put each of them at that incorrect time.
The event panel shows the JSON with the original time field.
GET /api/stats gives the number of these events, in the future field.
Clocks
Section titled “Clocks”streamview compares times from different computers. If the clocks of your producers are different, the sequence on the timeline can be incorrect. The times in a trace can then show an effect before its cause.