Class TestClock
java.lang.Object
io.opentelemetry.sdk.testing.time.TestClock
- All Implemented Interfaces:
io.opentelemetry.sdk.common.Clock
@ThreadSafe
public final class TestClock
extends Object
implements io.opentelemetry.sdk.common.Clock
A mutable
Clock that allows the time to be set for testing.-
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances the time and mutates this instance.voidAdvances the time and mutates this instance.static TestClockcreate()Creates a clock initialized to a constant non-zero time.static TestClockCreates a clock with the given time.longnanoTime()longnow()voidSets the current time.
-
Method Details
-
create
Creates a clock initialized to a constant non-zero time.- Returns:
- a clock initialized to a constant non-zero time.
-
create
Creates a clock with the given time. -
setTime
Sets the current time. -
advance
Advances the time and mutates this instance. -
advance
Advances the time and mutates this instance. -
now
public long now()- Specified by:
nowin interfaceio.opentelemetry.sdk.common.Clock
-
nanoTime
public long nanoTime()- Specified by:
nanoTimein interfaceio.opentelemetry.sdk.common.Clock
-