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 mutableClockthat allows the time to be set for testing.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvance(long duration, TimeUnit unit)Advances the time and mutates this instance.voidadvance(Duration duration)Advances the time and mutates this instance.static TestClockcreate()Creates a clock initialized to a constant non-zero time.static TestClockcreate(Instant instant)Creates a clock with the given time.longnanoTime()longnow()voidsetTime(Instant instant)Sets the current time.
-
-
-
Method Detail
-
create
public static TestClock create()
Creates a clock initialized to a constant non-zero time.- Returns:
- a clock initialized to a constant non-zero time.
-
setTime
public void setTime(Instant instant)
Sets the current time.
-
advance
public void advance(Duration duration)
Advances the time and mutates this instance.
-
advance
public void advance(long duration, TimeUnit unit)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
-
-