1 | /** @module trace */
|
2 | import { ITracer } from './ITracer';
|
3 | /**
|
4 | * Timing object returned by {@link ITracer.beginTrace} to end timing
|
5 | * of execution block and record the associated trace.
|
6 | *
|
7 | * ### Example ###
|
8 | *
|
9 | * let timing = tracer.beginTrace("mymethod.exec_time");
|
10 | * try {
|
11 | * ...
|
12 | * timing.endTrace();
|
13 | * } catch (err) {
|
14 | * timing.endFailure(err);
|
15 | * }
|
16 | *
|
17 | */
|
18 | export declare class TraceTiming {
|
19 | private _start;
|
20 | private _tracer;
|
21 | private _correlationId;
|
22 | private _component;
|
23 | private _operation;
|
24 | /**
|
25 | * Creates a new instance of the timing callback object.
|
26 | *
|
27 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
28 | * @param component an associated component name
|
29 | * @param operation an associated operation name
|
30 | * @param callback a callback that shall be called when endTiming is called.
|
31 | */
|
32 | constructor(correlationId: string, component: string, operation: string, tracer?: ITracer);
|
33 | /**
|
34 | * Ends timing of an execution block, calculates elapsed time
|
35 | * and records the associated trace.
|
36 | */
|
37 | endTrace(): void;
|
38 | /**
|
39 | * Ends timing of a failed block, calculates elapsed time
|
40 | * and records the associated trace.
|
41 | * @param error an error object associated with this trace.
|
42 | */
|
43 | endFailure(error: Error): void;
|
44 | }
|