1 | export interface Clock {
|
2 | /**
|
3 | * Return the current time in milliseconds from some epoch such as the Unix epoch or process start
|
4 | */
|
5 | now(): number;
|
6 | }
|
7 | /**
|
8 | * A utility for returning wall times anchored to a given point in time. Wall time measurements will
|
9 | * not be taken from the system, but instead are computed by adding a monotonic clock time
|
10 | * to the anchor point.
|
11 | *
|
12 | * This is needed because the system time can change and result in unexpected situations like
|
13 | * spans ending before they are started. Creating an anchored clock for each local root span
|
14 | * ensures that span timings and durations are accurate while preventing span times from drifting
|
15 | * too far from the system clock.
|
16 | *
|
17 | * Only creating an anchored clock once per local trace ensures span times are correct relative
|
18 | * to each other. For example, a child span will never have a start time before its parent even
|
19 | * if the system clock is corrected during the local trace.
|
20 | *
|
21 | * Heavily inspired by the OTel Java anchored clock
|
22 | * https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/AnchoredClock.java
|
23 | */
|
24 | export declare class AnchoredClock implements Clock {
|
25 | private _monotonicClock;
|
26 | private _epochMillis;
|
27 | private _performanceMillis;
|
28 | /**
|
29 | * Create a new AnchoredClock anchored to the current time returned by systemClock.
|
30 | *
|
31 | * @param systemClock should be a clock that returns the number of milliseconds since January 1 1970 such as Date
|
32 | * @param monotonicClock should be a clock that counts milliseconds monotonically such as window.performance or perf_hooks.performance
|
33 | */
|
34 | constructor(systemClock: Clock, monotonicClock: Clock);
|
35 | /**
|
36 | * Returns the current time by adding the number of milliseconds since the
|
37 | * AnchoredClock was created to the creation epoch time
|
38 | */
|
39 | now(): number;
|
40 | }
|
41 | //# sourceMappingURL=anchored-clock.d.ts.map |
\ | No newline at end of file |