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

filebeat @timestamp support nanoseconds #7576

Closed
wants to merge 1 commit into from
Closed

filebeat @timestamp support nanoseconds #7576

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 12, 2018

Hi! I am not an original author of this patch, though can contribute.

This PR

  • adds nanosecond support to dtfmt module
  • passes nanoseconds in @timestamp to downstream consumers

dtfmt 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 of S, in Java you can just append as much S 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

@elasticmachine
Copy link
Collaborator

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 {

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 {

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

@ruflin
Copy link
Contributor

ruflin commented Jul 13, 2018

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(),
Copy link

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.

Copy link

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?

Copy link

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()))
Copy link

Choose a reason for hiding this comment

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

Same here, choose one.

Copy link

@urso urso left a 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
Copy link

pytimer commented Dec 25, 2018

@ruflin @urso Very sorry, i have some thing during this time.

I will fix this PR according to @urso feedback.

@ruflin
Copy link
Contributor

ruflin commented Dec 27, 2018

@pytimer Great to hear. Also make sure to rebase on master as lots of things have change in the code base since then.

@pytimer
Copy link

pytimer commented Dec 28, 2018

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.

@ruflin
Copy link
Contributor

ruflin commented Dec 28, 2018

@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.

@pytimer
Copy link

pytimer commented Dec 28, 2018

@ruflin Thanks you reponse.

I open a new PR #9818 about it, and i hope you can check it. Thanks.

@urso
Copy link

urso commented Jan 2, 2019

Can we close this PR?

@botelastic
Copy link

botelastic bot commented Jul 8, 2020

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.

@botelastic botelastic bot added Stalled needs_team Indicates that the issue/PR needs a Team:* label labels Jul 8, 2020
@botelastic
Copy link

botelastic bot commented Jul 8, 2020

This pull request doesn't have a Team:<team> label.

@urso urso closed this Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement libbeat needs_team Indicates that the issue/PR needs a Team:* label review Stalled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants