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

Timestamp type assertion fails on darwin #10

Open
jasonkeene opened this issue Jun 28, 2018 · 2 comments
Open

Timestamp type assertion fails on darwin #10

jasonkeene opened this issue Jun 28, 2018 · 2 comments

Comments

@jasonkeene
Copy link

jasonkeene commented Jun 28, 2018

I ran my test suite for my plugin on macOS. The one thing that it had a problem with was type asserting the timestamp. I used this code from the gstdout example:

flbTime := ts.(output.FLBTime)

This caused the plugin to panic:

panic: interface conversion: interface {} is uint64, not output.FLBTime

goroutine 17 [running, locked to thread]:
main.FLBPluginFlush(0x7fb67180f000, 0xc40000001d, 0x7fb670602270, 0xc42005ced8)
	/Users/pivotal/workspace/foo/src/github.com/oratos/out_syslog/cmd/main.go:51 +0x25d
main._cgoexpwrap_44e740a65504_FLBPluginFlush(0x7fb67180f000, 0x1d, 0x7fb670602270, 0x0)
	_cgo_gotypes.go:82 +0x3d

Easy workaround was to just do:

var timestamp time.Time
flbTime, ok := ts.(output.FLBTime)
if ok {
    timestamp = flbTime.Time
} else {
    timestamp = time.Now()
}

If I can get a useful timestamp out of the uint64 I would prefer that.

@jasonkeene
Copy link
Author

I ran into this issue today while using https://github.com/fluent/fluent-logger-golang

The timestamps for the messages it emits into fluent-bit are interpreted as uint64 when handed off to the go output plugin. I discovered this uint64 is apparently unix seconds. Negative values were not allowed by fluent-logger-golang.

I will look into this further. I think at the very least fluent-bit should convert the uint64 into an output.FLBTime before handing it off to the output plugin.

@bgola-signalfx
Copy link

I believe the way it works is that when timestamp is available in the log record it is passed on to the plugin as FLBTime. On the other when timestamp is not available I believe FB provides current time as Unix time using uint64.

It would be great if FB always used one type in all cases, preferably regular Go time.Time struct.

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

No branches or pull requests

2 participants