-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix unit test to support Logstash 8 nano timestamp #67
Merged
kaisecheng
merged 6 commits into
logstash-plugins:main
from
kaisecheng:fix_ci_timestamp_nano
Jun 16, 2022
+54
−2
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0dee360
Fix unit test to support Logstash 8 nano timestamp
kaisecheng 0f6bd7a
update changelog
kaisecheng 955ce28
Revert "Fix unit test to support Logstash 8 nano timestamp"
kaisecheng c9fa5c5
test against static value
kaisecheng 6b9c75c
patch timestamp format to be backward compatible
kaisecheng 56a77a6
changelog
kaisecheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal with having explicit values was that we could compute the digests "manually" independently from the code we use in the plugin(e.g. https://cimi.io/murmurhash3js-revisited/). It's not clear if this change causes the digests of a few tests to change, or if it's just a code reorganization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the test fails in Logstash 8 due to the breaking change of nanosecond timestamp in elastic/logstash#12797 which changes the string format of
@timestamp
, as a result, the hash value change in Logstash 8.I can make a version specific hash value in test, or getting the value from
OpenSSL::Digest::SHA1.new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 because LS8's
Timestamp#to_s
does not include a trailing.000
for whole-second values, and does include.XXX
for timestamps with fractional seconds, this breaks the fingerprinting of timestamps in 1 out of 1000 events.Can we normalize the serialization in this library to include a minimum precision?
We could do it with refinements like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave a test record here
Logstash 7.17.0
Logstash 8.1.1
7.17 always gives three fractional digit while 8 formats fractional digits in groups of three.
The patch is good enough to make zero to three fractional digits backward compatible.
@yaauie I think your patch is the best fit for user. I am wondering is there any reason not to put
using MinimumSerializationLengthTimestamp
right afterMinimumSerializationLengthTimestamp
module?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refinement scoping can get... weird. They're active until the lexical scope in which the
using
is sent is closed, and affect methods that are defined while they are active, so my first thought was to minimize the scope in which it can be active by sending theusing
after defining other methods.Looking at the implementation though, I think you are right that they should be grouped together -- there is little risk of accidental timestamp serialization during the lexical scope or using the methods defined in this lexical scope.
The following diff makes the build green.
I would like to see:
Timestamp#new
on 7.x).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7.17.0
8.1.1
LogStash::Timestamp of
2000-01-01T05:00:00.12Z
is consistent with the patch. However, LogStash::Timestamp( Time -> RubyTime -> Instant ), RubyTime convert.12
to millisecond and 4 nanasecond.I think Logstash core is a better place to handle this case. I believe most of the use cases are converting from datetime string, except customized script in ruby filter, so the patch is still valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaauie I have created an issue to track the timestamp elastic/logstash#14088
Do you think we can merge the patch now?