-
Notifications
You must be signed in to change notification settings - Fork 20
Description
What's needed?
Hi,
while migrating to BatteryPool again, I noticed that data types like Sample, CapacityMetrics, PowerMetrics, SoCMetrics all feature a timestamp member of type datetime. I think it should not be of type datetime (e.g. be initialized to the result of the call datetime.now() because that is subject to jump arbitrarily forth and back at the will of the system administrator (e.g. sudo date -s ..., which potentially could break assumptions by a callee that is getting new metrics/samples being passed with the time jumping out of nowhere.
Proposed solution
Prefer a strong data type to enforce monotonic time clock use
Use cases
Improved resillience against external clock changes (sysop setting time, or computer going to sleep for various reasons)
Alternatives and workarounds
No response
Additional context
to guard against time jumps, it's usually typical to always favor monotonic clocks. I am not sure how far Frequenz-SDK users actually rely on forward-ticking clocks or if these timestamp values matter at all (for resampling I think they might, and there we should actually prefer monotonic clock, IMHO)