-
Notifications
You must be signed in to change notification settings - Fork 525
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
makes timestamp optional #819
Conversation
processor/transaction/payload.go
Outdated
@@ -65,6 +67,10 @@ func (pa *payload) transform(config config.Config) []beat.Event { | |||
|
|||
var events []beat.Event | |||
for _, event := range pa.Events { | |||
var zeroTime = time.Time{} | |||
if event.Timestamp == zeroTime { |
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.
Looks like this IsZero
method could be useful here: https://golang.org/pkg/time/#Time.IsZero
utility/data_fetcher.go
Outdated
@@ -145,6 +145,9 @@ func (d *ManualDecoder) MapStr(base map[string]interface{}, key string, keys ... | |||
|
|||
func (d *ManualDecoder) TimeRFC3339(base map[string]interface{}, key string, keys ...string) time.Time { | |||
val := getDeep(base, keys...)[key] | |||
if val == nil { | |||
return time.Time{} |
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.
How about introducing a TimeRFC3339WithDefault
method that returns a time.Now()
instead of a zero time in case it is empty? The decoding happens before the transformation, so the timestamp would be more accurate, and no further handling in the transform
function would be needed.
d47e7b1
to
8564f95
Compare
fixes #723