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 TypeMethodDescriptionvoid
Advances the time and mutates this instance.void
Advances the time and mutates this instance.static TestClock
create()
Creates a clock initialized to a constant non-zero time.static TestClock
Creates a clock with the given time.long
nanoTime()
long
now()
void
Sets 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:
now
in interfaceio.opentelemetry.sdk.common.Clock
-
nanoTime
public long nanoTime()- Specified by:
nanoTime
in interfaceio.opentelemetry.sdk.common.Clock
-