Skip to content

Channelz should use milliseconds for timestamps #5494

Closed

Description

@zhangkun83

#4883 changed the TimeProvider.currentTimeNanos()'s precision to milliseconds, because there isn't a way to get the current time in nanoseconds precision. After #5056 is fixed, Channelz/ChannelTracer will be the only users of TimeProvider, and they all convert the time to proto Timestamp which doesn't mandate the unit. It will only be misleading to keep TimeProvider.currentTimeNanos() as is. It should be changed to currentTimeMillis().

Activity

  1. carl-mastrangelo commented on Mar 25, 2019

    @carl-mastrangelo
    Contributor

    I'm going to disagree a little here. Two reasons:

    1. When we (eventually) move to Java 8, the time API does provide nanosecond precise timestamp
    2. Keeping all timestamps in gRPC as the same unit simplifies reading the code, and no conversions are necessary. Nanoseconds everywhere (except on API boundaries) are the most reasonable choice.
  2. added this to the Next milestone on Mar 26, 2019
  3. dapengzhang0 commented on Mar 29, 2019

    @dapengzhang0
    Contributor

    One more factor to consider: the channelz service uses timestamp.proto, so when you create a timestamp message, you have to use its nano precision API, and if you have a millis variable, you still have to cast it to nano at some point.

  4. vinodhabib commented on Oct 4, 2024

    @vinodhabib
    Contributor

    Started Analysis and going through previous comments/details.

  5. zhangkun83 commented on Oct 4, 2024

    @zhangkun83
    ContributorAuthor

    I agree with @dapengzhang0's last comment. It is more convenient to use nanos to create timestamp.proto timestamps. We can now change SYSTEM_TIME_PROVIDER to use Java 8 Instant.getNano() to get nano precision. I didn't find a way to get the current epoch nanos directly, so you'd still have to combine the seconds part and the nanos part from Instant.

  6. ejona86 commented on Oct 17, 2024

    @ejona86
    Member

    It is more convenient to use nanos to create timestamp.proto timestamps

    The TimeProvider API is already using nanos, so there's no change needed here. It's just what resolution the actual values use.

  7. added a commit that references this issue on Oct 29, 2024
    9176b55
  8. modified the milestones: Next, 1.69 on Nov 11, 2024
  9. locked as resolved and limited conversation to collaborators on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions