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

DataFluentAppender generates new timestamp instead of event's time #66

Open
discorpsee opened this issue May 28, 2022 · 1 comment
Open

Comments

@discorpsee
Copy link

Why does DataFluentAppender generates brand new timestamp?

Probles arises when AsyncAppender thread not as fast as we desire. With some network delay or queue problems elastic's timestamp becames significantly later then real log event.

protected void append(E event) {
    Map<String, Object> data = createData(event);

    if (isUseEventTime()) {
        fluentLogger.log(getLabel() == null ? getTag() : getLabel(), data, System.currentTimeMillis() / 1000);
    } else {
        fluentLogger.log(getLabel() == null ? getTag() : getLabel(), data);
    }
}

I can create PR with changes like that, is it useful for this repo?

protected void append(E event) {
    Map<String, Object> data = createData(event);

    if (isUseEventTime()) {
        fluentLogger.log(getLabel() == null ? getTag() : getLabel(), data, getTimestamp(event) / 1000);
    } else {
        fluentLogger.log(getLabel() == null ? getTag() : getLabel(), data);
    }
}

protected long getTimestamp(E event) {
    if (event instanceof ILoggingEvent) {
        return ((ILoggingEvent) event).getTimeStamp();
    }
    return System.currentTimeMillis();
}
  • it looses milliseconds cause of division, why so?
@sndyuk
Copy link
Owner

sndyuk commented May 29, 2022

@discorpsee I think, you are right. That PR would be great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants