netwatcherio/netwatcher-agent

Timestamp Issues

Closed this issue · 1 comments

If I recall correctly, there was a few timestamp issues where the received data does not have the correct completion timestamp or any timestamp at all.

The issue might be with the time zones. It would be best to store all time stamps as UTC as to prevent this. Go even supports UTC Nano which provides a great resolution. You might go with a singlet global object to keep track of each interaction by an event UUID. See https://github.com/bradenn/udap/blob/2.19.0B/internal/pulse/pulse.go for a potential implementation.

You can use it like this:

addr := fmt.Sprintf("module.%s.update", module.UUID)
// Mark the time that the update begins
pulse.Begin(addr)
// End the pulse when the update concludes or errors out
defer pulse.End(addr)
// Attempt to update the modules
err = u.operator.Update(module.UUID)
if err != nil {
return err
}

The above example measures the runtime of the Update function for a module with a UUID and stores the data in a central object connected to the address made in the addr variable.

Then you can retrieve the data later and process it. This eliminates the timing delays of the logic.