1 |
|
2 | import { ConfigParams } from 'pip-services3-commons-node';
|
3 | import { IReferenceable } from 'pip-services3-commons-node';
|
4 | import { IReferences } from 'pip-services3-commons-node';
|
5 | import { IReconfigurable } from 'pip-services3-commons-node';
|
6 | import { ITracer } from './ITracer';
|
7 | import { TraceTiming } from './TraceTiming';
|
8 | import { OperationTrace } from './OperationTrace';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare abstract class CachedTracer implements ITracer, IReconfigurable, IReferenceable {
|
28 | protected _source: string;
|
29 | protected _cache: OperationTrace[];
|
30 | protected _updated: boolean;
|
31 | protected _lastDumpTime: number;
|
32 | protected _maxCacheSize: number;
|
33 | protected _interval: number;
|
34 | |
35 |
|
36 |
|
37 | constructor();
|
38 | /**
|
39 | * Configures component by passing configuration parameters.
|
40 | *
|
41 | * @param config configuration parameters to be set.
|
42 | */
|
43 | configure(config: ConfigParams): void;
|
44 | /**
|
45 | * Sets references to dependent components.
|
46 | *
|
47 | * @param references references to locate the component dependencies.
|
48 | */
|
49 | setReferences(references: IReferences): void;
|
50 | /**
|
51 | * Writes a log message to the logger destination.
|
52 | *
|
53 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
54 | * @param component a name of called component
|
55 | * @param operation a name of the executed operation.
|
56 | * @param error an error object associated with this trace.
|
57 | * @param duration execution duration in milliseconds.
|
58 | */
|
59 | protected write(correlationId: string, component: string, operation: string, error: Error, duration: number): void;
|
60 | /**
|
61 | * Records an operation trace with its name and duration
|
62 | *
|
63 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
64 | * @param component a name of called component
|
65 | * @param operation a name of the executed operation.
|
66 | * @param duration execution duration in milliseconds.
|
67 | */
|
68 | trace(correlationId: string, component: string, operation: string, duration: number): void;
|
69 | /**
|
70 | * Records an operation failure with its name, duration and error
|
71 | *
|
72 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
73 | * @param component a name of called component
|
74 | * @param operation a name of the executed operation.
|
75 | * @param error an error object associated with this trace.
|
76 | * @param duration execution duration in milliseconds.
|
77 | */
|
78 | failure(correlationId: string, component: string, operation: string, error: Error, duration: number): void;
|
79 | /**
|
80 | * Begings recording an operation trace
|
81 | *
|
82 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
83 | * @param component a name of called component
|
84 | * @param operation a name of the executed operation.
|
85 | * @returns a trace timing object.
|
86 | */
|
87 | beginTrace(correlationId: string, component: string, operation: string): TraceTiming;
|
88 | /**
|
89 | * Saves log messages from the cache.
|
90 | *
|
91 | * @param messages a list with log messages
|
92 | * @param callback callback function that receives error or null for success.
|
93 | */
|
94 | protected abstract save(messages: OperationTrace[], callback: (err: any) => void): void;
|
95 | /**
|
96 | * Clears (removes) all cached log messages.
|
97 | */
|
98 | clear(): void;
|
99 | /**
|
100 | * Dumps (writes) the currently cached log messages.
|
101 | *
|
102 | * @see [[write]]
|
103 | */
|
104 | dump(): void;
|
105 | /**
|
106 | * Makes trace cache as updated
|
107 | * and dumps it when timeout expires.
|
108 | *
|
109 | * @see [[dump]]
|
110 | */
|
111 | protected update(): void;
|
112 | }
|