-
Notifications
You must be signed in to change notification settings - Fork 906
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
Instrumenter.getNanos() returns non-epoch timestamp. #13295
Comments
hi @wdengw! this is intentional, and should only be used to measure duration (against other calls to System.nanoTime) is there a specific problem this is causing for you? it does look like we pass this value to OperationListeners, and probably should make clear that this isn't a "timestamp" as the OperationListener javadoc seems to suggest: |
|
We followed the same logic to implement our tracing instrumentation. When calling Span.addEvent() method to add an event, we passed in the timestamp created from a similar getNanos() method. That led us to discover this discrepancy. |
Just because |
This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment. |
@laurit and @trask, Instrumenter.getNanos() is called in two places: Instrumenter.doStart() and Instrumenter.doEnd(). If a span is started by calling Instrumenter.doStart() with a null startTime argument and is ended by calling Instrumenter.doEnd() with a non-null endTime argument, the calculated duration for this span will be incorrect. Here is the test code to demonstrate the calculated durations:
Following is the outputs
|
Describe the bug
Instrumenter.getNanos() at line number 269 returns System.nanoTime() which is not a valid epoch timestamp. Should we consider to use
to replace it?
Steps to reproduce
The difference between the two can be seen by System.print(...) both returned times.
Expected behavior
The Instrumenter.getNanos() should return epoch timestamp.
Actual behavior
The Instrumenter.getNanos() returns non epoch timestamp.
Javaagent or library instrumentation version
The current version on main.
Environment
JDK:
OS:
Additional context
No response
The text was updated successfully, but these errors were encountered: