1 | /** @module count */
|
2 | import { CounterTiming } from './CounterTiming';
|
3 | /**
|
4 | * Interface for performance counters that measure execution metrics.
|
5 | *
|
6 | * The performance counters measure how code is performing:
|
7 | * how fast or slow, how many transactions performed, how many objects
|
8 | * are stored, what was the latest transaction time and so on.
|
9 | *
|
10 | * They are critical to monitor and improve performance, scalability
|
11 | * and reliability of code in production.
|
12 | */
|
13 | export interface ICounters {
|
14 | /**
|
15 | * Begins measurement of execution time interval.
|
16 | * It returns [[CounterTiming]] object which has to be called at
|
17 | * [[CounterTiming.endTiming]] to end the measurement and update the counter.
|
18 | *
|
19 | * @param name a counter name of Interval type.
|
20 | * @returns a [[CounterTiming]] callback object to end timing.
|
21 | */
|
22 | beginTiming(name: string): CounterTiming;
|
23 | /**
|
24 | * Calculates min/average/max statistics based on the current and previous values.
|
25 | *
|
26 | * @param name a counter name of Statistics type
|
27 | * @param value a value to update statistics
|
28 | */
|
29 | stats(name: string, value: number): void;
|
30 | /**
|
31 | * Records the last calculated measurement value.
|
32 | *
|
33 | * Usually this method is used by metrics calculated
|
34 | * externally.
|
35 | *
|
36 | * @param name a counter name of Last type.
|
37 | * @param value a last value to record.
|
38 | */
|
39 | last(name: string, value: number): void;
|
40 | /**
|
41 | * Records the current time as a timestamp.
|
42 | *
|
43 | * @param name a counter name of Timestamp type.
|
44 | */
|
45 | timestampNow(name: string): void;
|
46 | /**
|
47 | * Records the given timestamp.
|
48 | *
|
49 | * @param name a counter name of Timestamp type.
|
50 | * @param value a timestamp to record.
|
51 | */
|
52 | timestamp(name: string, value: Date): void;
|
53 | /**
|
54 | * Increments counter by 1.
|
55 | *
|
56 | * @param name a counter name of Increment type.
|
57 | */
|
58 | incrementOne(name: string): void;
|
59 | /**
|
60 | * Increments counter by given value.
|
61 | *
|
62 | * @param name a counter name of Increment type.
|
63 | * @param value a value to add to the counter.
|
64 | */
|
65 | increment(name: string, value: number): void;
|
66 | }
|