Skip to content

Prefer monotonic clock for timestamp in Sample and all other FooMetrics #468

@christianparpart

Description

@christianparpart

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    part:❓We need to figure out which part is affectedpriority:❓We need to figure out how soon this should be addressedtype:enhancementNew feature or enhancement visitble to users

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions