Skip to content

Improve nanosecond timestamp support. #12

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

Merged
merged 2 commits into from
May 12, 2015
Merged

Improve nanosecond timestamp support. #12

merged 2 commits into from
May 12, 2015

Conversation

mr-salty
Copy link
Contributor

  • timeNanos is deprecated because the 53 bit mantissa used for doubles
    does not have sufficient precision to represent the current time in
    nanoseconds past the unix epoch (which currently requires 61 bits).

  • instead, we now support formats with split seconds and nanoseconds:

    • timestampSeconds, timestampNanos
    • timestamp { seconds, nanos }

    In both cases, the "seconds" part represents seconds since the unix epoch,
    and the "nano" part is the nanosecond component only (0..999999999).

    Managed VMs is using the latter, but it can only be ingested via
    json/msgpack/etc, while the former is suitable for use in an in_tail regex.

This should be considered an interim solution until
fluent/fluentd#461 is resolved.

- timeNanos is deprecated because the 53 bit mantissa used for doubles
  does not have sufficient precision to represent the current time in
  nanoseconds past the unix epoch (which currently requires 61 bits).
- instead, we now support formats with split seconds and nanoseconds:
  - timestampSeconds, timestampNanos
  - timestamp { seconds, nanos }
  In both cases, the "seconds" part represents seconds since the unix epoch,
  and the "nano" part is the nanosecond component only (0..999999999).
  Managed VMs is using the latter, but it can only be ingested via
  json/msgpack/etc, while the former is suitable for use in an in_tail regex.

This should be considered an interim solution until
fluent/fluentd#461 is resolved.
if (record.has_key?('timeNanos'))
if (record.has_key?('timestamp') &&
record['timestamp'].has_key?('seconds') &&
record['timestamp'].has_key?('nanos'))
Copy link

Choose a reason for hiding this comment

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

If a user wants to only use seconds can he make a config that will automatically set "nanos" to zero?
If not, then maybe treat unset "nanos" as 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I debated that but decided not to - since this is an interim step I really only want people to use this if they have a need, and whole seconds can already be handled by the native fluentd "time" using time_format %s.

@filipjs
Copy link

filipjs commented May 11, 2015

LGTM

mr-salty added a commit that referenced this pull request May 12, 2015
Improve nanosecond timestamp support.
@mr-salty mr-salty merged commit e376ab9 into master May 12, 2015
@mr-salty mr-salty deleted the timestamp branch May 19, 2015 21:27
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

Successfully merging this pull request may close these issues.

3 participants