1 | /** @module count */
|
2 | import { IReferenceable } from 'pip-services3-commons-node';
|
3 | import { IReferences } from 'pip-services3-commons-node';
|
4 | import { Counter } from './Counter';
|
5 | import { CachedCounters } from './CachedCounters';
|
6 | /**
|
7 | * Performance counters that periodically dumps counters measurements to logger.
|
8 | *
|
9 | * ### Configuration parameters ###
|
10 | *
|
11 | * - __options:__
|
12 | * - interval: interval in milliseconds to save current counters measurements (default: 5 mins)
|
13 | * - reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)
|
14 | *
|
15 | * ### References ###
|
16 | *
|
17 | * - <code>\*:logger:\*:\*:1.0</code> [[ILogger]] components to dump the captured counters
|
18 | * - <code>\*:context-info:\*:\*:1.0</code> (optional) [[ContextInfo]] to detect the context id and specify counters source
|
19 | *
|
20 | * @see [[Counter]]
|
21 | * @see [[CachedCounters]]
|
22 | * @see [[CompositeLogger]]
|
23 | *
|
24 | * ### Example ###
|
25 | *
|
26 | * let counters = new LogCounters();
|
27 | * counters.setReferences(References.fromTuples(
|
28 | * new Descriptor("pip-services", "logger", "console", "default", "1.0"), new ConsoleLogger()
|
29 | * ));
|
30 | *
|
31 | * counters.increment("mycomponent.mymethod.calls");
|
32 | * let timing = counters.beginTiming("mycomponent.mymethod.exec_time");
|
33 | * try {
|
34 | * ...
|
35 | * } finally {
|
36 | * timing.endTiming();
|
37 | * }
|
38 | *
|
39 | * counters.dump();
|
40 | */
|
41 | export declare class LogCounters extends CachedCounters implements IReferenceable {
|
42 | private readonly _logger;
|
43 | /**
|
44 | * Creates a new instance of the counters.
|
45 | */
|
46 | constructor();
|
47 | /**
|
48 | * Sets references to dependent components.
|
49 | *
|
50 | * @param references references to locate the component dependencies.
|
51 | *
|
52 | */
|
53 | setReferences(references: IReferences): void;
|
54 | private counterToString;
|
55 | /**
|
56 | * Saves the current counters measurements.
|
57 | *
|
58 | * @param counters current counters measurements to be saves.
|
59 | */
|
60 | protected save(counters: Counter[]): void;
|
61 | }
|