1 | import { IMetricListener } from "./IMetricListener";
|
2 | import { IMetricContext } from "./contexts";
|
3 | /**
|
4 | * Tracks metrics.
|
5 | * @category Metrics
|
6 | */
|
7 | export declare class Metrics {
|
8 | private listeners;
|
9 | private requestStartTimes;
|
10 | private uid;
|
11 | /**
|
12 | * Creates a new Metrics handler with optional parent handler. When
|
13 | * a parent handler is defined, metrics will be automatically published
|
14 | * upwards to the parent.
|
15 | * @param {Metrics} parent Optional parent for upstream metrics.
|
16 | */
|
17 | constructor(parent?: Metrics);
|
18 | /**
|
19 | * Registers a metric listener.
|
20 | * @param {IMetricListener} listener The listener.
|
21 | */
|
22 | registerListener(listener: IMetricListener): void;
|
23 | /**
|
24 | * De-registers a metric listener.
|
25 | * @param {IMetricListener} listener The listener.
|
26 | */
|
27 | unregisterListener(listener: IMetricListener): void;
|
28 | /**
|
29 | * Starts a timer on a metric.
|
30 | * @param {string} metricName The metric name.
|
31 | * @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
32 | */
|
33 | start(metricName: string, context: IMetricContext): void;
|
34 | /**
|
35 | * Ends a timer on a metric.
|
36 | * @param {string} metricName The metric name.
|
37 | * @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
38 | */
|
39 | end(metricName: string, context: IMetricContext): void;
|
40 | /**
|
41 | * Increments a metric.
|
42 | * @param {string} metricName The metric name.
|
43 | * @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
44 | * @param {number} amount The amount.
|
45 | */
|
46 | increment(metricName: string, context: IMetricContext, amount: number): void;
|
47 | /**
|
48 | * Decrements a metric.
|
49 | * @param {string} metricName The metric name.
|
50 | * @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
51 | * @param {number} amount The amount.
|
52 | */
|
53 | decrement(metricName: string, context: IMetricContext, amount: number): void;
|
54 | /**
|
55 | * Resets a metric.
|
56 | * @param {string} metricName The metric name.
|
57 | * @param {IMetricContext} context The metric context. Expected to have a unique ID.
|
58 | */
|
59 | reset(metricName: string, context: IMetricContext): void;
|
60 | /**
|
61 | * Assigns a unique ID to the context object, returning it back.
|
62 | * @param {IMetricContext} context The context to modify.
|
63 | * @returns {IMetricContext} The provided context.
|
64 | */
|
65 | assignUniqueContextId(context: IMetricContext): IMetricContext;
|
66 | }
|