Skip to content

Conversation

@atulgpt
Copy link
Contributor

@atulgpt atulgpt commented Nov 11, 2025

…edRealtimeNanos()`

Fixes #1364

But doesn't make it overridable

@fractalwrench
Copy link
Member

I think we can improve this using the suggestions stated here: #1364 (comment)

@atulgpt
Copy link
Contributor Author

atulgpt commented Nov 13, 2025

Hi @fractalwrench the definition of nanoTime is as below(taken from io.opentelemetry.sdk.common.Clock)

  /**
   * Returns a time measurement with nanosecond precision that can only be used to calculate elapsed
   * time.
   */

so this API is only suitable for calculating the elapsed time. So do we need to do what you are suggesting?

@fractalwrench
Copy link
Member

nanoTime does not guarantee any correlation to wall-clock time. OTLP requires a timestamp - i.e. elapsed nanoseconds since the Unix epoch.

@atulgpt
Copy link
Contributor Author

atulgpt commented Nov 13, 2025

OTLP requires a [timestamp](https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-timestamp) - i.e. elapsed nanoseconds since the Unix epoch. but for this there are other functions in io.opentelemetry.sdk.common.Clock which are now and now(boolean highPrecision) both returns timestamp in nano since epoch.

That's why I was asking do we want to change the behavior of the third method nanoTime which is documented to use only for elapsed time?

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.

Clock.getDefault() isn’t configurable; add platform-aware selection & override hooks

2 participants