Skip to content

wip add timestamp to server owned call#1504

Draft
eddbbt wants to merge 2 commits into
astarte-platform:release-1.3from
eddbbt:timestamp_server_own
Draft

wip add timestamp to server owned call#1504
eddbbt wants to merge 2 commits into
astarte-platform:release-1.3from
eddbbt:timestamp_server_own

Conversation

@eddbbt
Copy link
Copy Markdown
Collaborator

@eddbbt eddbbt commented Sep 9, 2025

addedd timestamp to message received, like (it was empty)

16:27:22.811 [info] Message received: %Astarte.Device.Handler.Message{timestamp: ~U[2025-09-10 14:27:22.778Z], realm: "test", device_id: "V2Zw_JyRTEGLKwl8VBhKsQ", interface_name: "org.astarteplatform.examples.ServerDatastream", path_tokens: ["boolean_endpoint"], value: true}

@github-actions github-actions Bot added the size/s label Sep 9, 2025
@eddbbt eddbbt force-pushed the timestamp_server_own branch from bf4e5c7 to 8b243df Compare September 9, 2025 16:02
Signed-off-by: Eddy Babetto <eddy.babetto@secomind.com>
Signed-off-by: Eddy Babetto <eddy.babetto@secomind.com>
@eddbbt eddbbt force-pushed the timestamp_server_own branch from 891ad5c to 4646234 Compare September 10, 2025 14:50
path,
value
value,
timestamp: timestamp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous behavior did not set the timestamp, resulting in a map with only the :v key being set

after this change, we will always set the :t key in the value we send to the device

I believe the device only sets the timestamp when the value has explicit timestamp, my gut feeling says we should do the same BUT we can ask the embedded team for their opinion on the matter

Comment on lines +383 to +386
case explicit_timestamp do
false -> DateTime.utc_now()
{:ok, timestamp} -> timestamp
end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fact that this value can be either false (a boolean) or {:ok, timestamp} (a tuple) is quite cursed. I suggest either making it a classic result

case explicit_timestamp do
  {:ok, timestamp} -> timestamp
  :error -> DateTime.utc_now()
end

or just having a nullable datetime

) do
now = DateTime.utc_now()
# check for explicit timestamp
now =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe value_timestamp better reflects the intent, now worked when it was only "now"


explicit_timestamp =
with true <-
Queries.interface_has_explicit_timestamp?(realm_name, interface_row.interface_id),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in their respective functions (update_{individual,object}_interface_values), we're already querying for the mappings

I think we can avoid this extra query by just delaying setting the timestamp until after we've read the mappings from the db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants