Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: Add support for specifying UTC offset changes in an IR stream. #386

Merged
merged 19 commits into from
Jun 1, 2024

Conversation

LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented May 7, 2024

References

Description

In the current IR format, the timezone information is specified at the beginning of the stream in the metadata, represented using IANA timezone ID. However, this format doesn't allow users to change the timezone in a stream. Therefore, this PR makes the following changes as a solution:

  • Add a packet to indicate timezone changes. The timezone information is presented as an offset to UTC. This offset is in minute precision to support the GPS clock. The Timezone package starts with a tag byte and always comes before a serialized log event. As a change to the IR format, this bumps the format version to 0.0.2.
  • An UTC offset will be associated with each deserialized log event. This means the timezone information is presented as per-log-event instead of per-stream.
  • Add unit tests to ensure UTC offsets can be deserialized properly.

Note:

  • IANA timezone ID should be deprecated in the future PR.
  • TimestampPattern does not have UTC offset support yet.

Validation performed

  • Add unit tests and ensure they worked as expected.
  • Ensure workflow passed.

Note: clang-tidy isn't fully applied since these files contain code using old styles.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file has been refactored to reduce code duplication. However, it contains many legacy codes, such as using static functions. We should refactor things in another PR.

@jackluo923
Copy link
Member

Can we modify the timestamp offset to either milliseconds? There are multiple benefits for storing offset in higher precision.

  1. GPS clock is currently around 18 seconds away from UTC.
  2. ISO-8601-2 timestamp standard offers finer granularity of time offsets than second.

@jackluo923 jackluo923 assigned jackluo923 and unassigned jackluo923 May 7, 2024
@LinZhihao-723
Copy link
Member Author

@kirkrodrigues Do you think we should add a field for UTC offset in LogEvent class and store it in every deserialized instance?

@LinZhihao-723
Copy link
Member Author

Can we modify the timestamp offset to either milliseconds? There are multiple benefits for storing offset in higher precision.

  1. GPS clock is currently around 18 seconds away from UTC.
  2. ISO-8601-2 timestamp standard offers finer granularity of time offsets than second.

Fixed

@kirkrodrigues
Copy link
Member

@kirkrodrigues Do you think we should add a field for UTC offset in LogEvent class and store it in every deserialized instance?

Sgtm

@LinZhihao-723
Copy link
Member Author

@kirkrodrigues Do you think we should add a field for UTC offset in LogEvent class and store it in every deserialized instance?

Sgtm

Done

components/core/src/clp/time_types.hpp Outdated Show resolved Hide resolved
components/core/src/clp/ffi/ir_stream/encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/src/clp/ir/LogEvent.hpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
Comment on lines +704 to +714
epoch_time_ms_t preamble_ts = get_current_ts();
constexpr char timestamp_pattern[] = "%Y-%m-%d %H:%M:%S,%3";
constexpr char timestamp_pattern_syntax[] = "yyyy-MM-dd HH:mm:ss";
constexpr char time_zone_id[] = "Asia/Tokyo";
REQUIRE(serialize_preamble<TestType>(
timestamp_pattern,
timestamp_pattern_syntax,
time_zone_id,
preamble_ts,
ir_buf
));
Copy link
Member

Choose a reason for hiding this comment

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

Can we deduplicate this as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

In decode_ir_complete, we need to use these variables for comparison. I would prefer to leave them verbose

components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

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

A few things I forgot to post in the last review.

components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
components/core/tests/test-ir_encoding_methods.cpp Outdated Show resolved Hide resolved
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
@kirkrodrigues kirkrodrigues changed the title Add support for specifying UTC offset changes in the IR stream. ffi: Add support for specifying UTC offset changes in an IR stream. Jun 1, 2024
@kirkrodrigues kirkrodrigues merged commit e45c869 into y-scope:main Jun 1, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants