Package io.opentelemetry.sdk.trace
Class AnchoredClock
java.lang.Object
io.opentelemetry.sdk.trace.AnchoredClock
A utility for returning wall times anchored to a given point in time. Wall time measurements will
not be taken from the system, but instead are computed by adding monotonic time to the anchor point.
This is needed because Java has lower granularity for epoch times and tracing events are recorded more often. There is also a performance improvement in avoiding referencing the system's wall time where possible. Instead of computing a true wall time for every timestamp within a trace, we compute it once at the local root and then anchor all descendant span timestamps to this root's timestamp.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AnchoredClock
Returns aAnchoredClock
.(package private) long
now()
Returns the current epoch timestamp in nanos calculated usingSystem.nanoTime()
since the reference time read in the constructor.(package private) long
Returns the start time in nanos of thisAnchoredClock
.
-
Field Details
-
clock
-
epochNanos
private final long epochNanos -
nanoTime
private final long nanoTime
-
-
Constructor Details
-
AnchoredClock
-
-
Method Details
-
create
Returns aAnchoredClock
.- Parameters:
clock
- theClock
to be used to read the current epoch time and nanoTime.- Returns:
- a
MonotonicClock
.
-
now
long now()Returns the current epoch timestamp in nanos calculated usingSystem.nanoTime()
since the reference time read in the constructor. This time can be used for computing durations.- Returns:
- the current epoch timestamp in nanos.
-
startTime
long startTime()Returns the start time in nanos of thisAnchoredClock
.
-