-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
filebeat @timestamp support nanoseconds #7576
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
} | ||
} | ||
|
||
func MakeBCNanoTimestampEncoder() func(*common.Time, structform.ExtVisitor) error { |
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.
exported function MakeBCNanoTimestampEncoder should have comment or be unexported
@@ -33,3 +33,29 @@ func MakeBCTimestampEncoder() func(*common.Time, structform.ExtVisitor) error { | |||
return enc((*time.Time)(t), v) | |||
} | |||
} | |||
|
|||
func MakeNanoTimestampEncoder() func(*time.Time, structform.ExtVisitor) error { |
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.
exported function MakeNanoTimestampEncoder should have comment or be unexported
Thanks for the contribution. We also had an internal discussion on if this should be turned on by default for all future release or not. We came to the conclusion that this is not a breaking change and we can have it on by default, no config option needed. @urso Could you have a look? |
@@ -58,6 +58,8 @@ func (e *Encoder) reset() { | |||
gotype.Folders( | |||
codec.MakeTimestampEncoder(), | |||
codec.MakeBCTimestampEncoder(), | |||
codec.MakeNanoTimestampEncoder(), | |||
codec.MakeBCNanoTimestampEncoder(), |
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.
choose one, but not both. MakeTimestampEncoder and MakeNanoTimestampEncoder have the same function signature. So to not confuse setup, select only one. Note to myself: add panic if encoders with same signature are passed.
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.
@urso you mean that remove codec.MakeTimestampEncoder()
and codec.MakeBCTimestampEncoder()
function from gotype.Folders
, is it?
Note to myself: add panic if encoders with same signature are passed.
I don't know what mean. MakeNanoTimestampEncoder
has add panic, you can check https://github.com/elastic/beats/pull/7576/files/8996d4f0e27415eb7d390ccc0da694bad76969bf#diff-1983a46731b9d0b0b4bc88ec99b97794R41. Or other changes?
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.
Yes, remove them.
The encoder uses reflection to choose the right function depending on the function paramters and actual type. One type must have only one function registered. e.g. MakeTimestampEncoder
and MakeNanoTimestampEncoder
have the same type func(*time.Time, structform.ExtVisitor) error
. Which one shall the encoder use?
MakeNanoTimestampEncoder has add panic, you can check /pull/7576/files/8996d4f0e27415eb7d390ccc0da694bad76969bf#diff-1983a46731b9d0b0b4bc88ec99b97794R41. Or other changes?
Stack-trace with content of actual error message would be helpful. I guess you mean the panic in the error right after dtfmt.NewFormatter
?
codec.MakeBCTimestampEncoder())) | ||
codec.MakeBCTimestampEncoder(), | ||
codec.MakeNanoTimestampEncoder(), | ||
codec.MakeBCNanoTimestampEncoder())) |
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.
Same here, choose one.
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.
+1 on adding nanosecond support. Please add tests to dfmt_test.go as well.
@pytimer Great to hear. Also make sure to rebase on master as lots of things have change in the code base since then. |
Hi @ruflin I encountered a question that i send a new commit, but it can not auto related to this PR. My commit is pytimer@605733d What should i do, Can you tell me? Thanks. |
@pytimer As it is not your PR you can't push to it. I recommend you to open your own PR and from there mention this PR that it's a follow up / take over of the PR. |
Can we close this PR? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull request doesn't have a |
Hi! I am not an original author of this patch, though can contribute.
This PR
@timestamp
to downstream consumersdtfmt is basically created similar to DateTimeFormat from the Joda Time. It does not support nanosecond precision, though Java itself can now parse nanoseconds which was introduced with JSR-310. The format is slightly different, with this PR you should use
n
for fractional digits instead ofS
, in Java you can just append as muchS
as you want. We've tested this and it seems to work, now we need more thorough review from experienced contributors. I'm not familiar with Go programming but can spent some time to make fixes if needed.Thanks!
Related GitHub issue: #7559
Discuss topic: https://discuss.elastic.co/t/low-timestamp-precision-cause-wrong-order-of-events-with-docker-input/137051/4