UNPKG

4.1 kBTypeScriptView Raw
1import type { TransactionContext } from '@sentry/types';
2import type { Hub } from '../hub';
3import type { Span } from './span';
4import { SpanRecorder } from './span';
5import { Transaction } from './transaction';
6export declare const TRACING_DEFAULTS: {
7 idleTimeout: number;
8 finalTimeout: number;
9 heartbeatInterval: number;
10};
11/**
12 * @inheritDoc
13 */
14export declare class IdleTransactionSpanRecorder extends SpanRecorder {
15 private readonly _pushActivity;
16 private readonly _popActivity;
17 transactionSpanId: string;
18 constructor(_pushActivity: (id: string) => void, _popActivity: (id: string) => void, transactionSpanId: string, maxlen?: number);
19 /**
20 * @inheritDoc
21 */
22 add(span: Span): void;
23}
24export declare type BeforeFinishCallback = (transactionSpan: IdleTransaction, endTimestamp: number) => void;
25/**
26 * An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities.
27 * You can have multiple IdleTransactions active, but if the `onScope` option is specified, the idle transaction will
28 * put itself on the scope on creation.
29 */
30export declare class IdleTransaction extends Transaction {
31 private readonly _idleHub;
32 /**
33 * The time to wait in ms until the idle transaction will be finished. This timer is started each time
34 * there are no active spans on this transaction.
35 */
36 private readonly _idleTimeout;
37 /**
38 * The final value in ms that a transaction cannot exceed
39 */
40 private readonly _finalTimeout;
41 private readonly _heartbeatInterval;
42 private readonly _onScope;
43 activities: Record<string, boolean>;
44 private _prevHeartbeatString;
45 private _heartbeatCounter;
46 private _finished;
47 private _idleTimeoutCanceledPermanently;
48 private readonly _beforeFinishCallbacks;
49 /**
50 * Timer that tracks Transaction idleTimeout
51 */
52 private _idleTimeoutID;
53 private _finishReason;
54 constructor(transactionContext: TransactionContext, _idleHub: Hub,
55 /**
56 * The time to wait in ms until the idle transaction will be finished. This timer is started each time
57 * there are no active spans on this transaction.
58 */
59 _idleTimeout?: number,
60 /**
61 * The final value in ms that a transaction cannot exceed
62 */
63 _finalTimeout?: number, _heartbeatInterval?: number, _onScope?: boolean);
64 /** {@inheritDoc} */
65 finish(endTimestamp?: number): string | undefined;
66 /**
67 * Register a callback function that gets excecuted before the transaction finishes.
68 * Useful for cleanup or if you want to add any additional spans based on current context.
69 *
70 * This is exposed because users have no other way of running something before an idle transaction
71 * finishes.
72 */
73 registerBeforeFinishCallback(callback: BeforeFinishCallback): void;
74 /**
75 * @inheritDoc
76 */
77 initSpanRecorder(maxlen?: number): void;
78 /**
79 * Cancels the existing idle timeout, if there is one.
80 * @param restartOnChildSpanChange Default is `true`.
81 * If set to false the transaction will end
82 * with the last child span.
83 */
84 cancelIdleTimeout(endTimestamp?: Parameters<IdleTransaction['finish']>[0], { restartOnChildSpanChange, }?: {
85 restartOnChildSpanChange?: boolean;
86 }): void;
87 /**
88 * Restarts idle timeout, if there is no running idle timeout it will start one.
89 */
90 private _restartIdleTimeout;
91 /**
92 * Start tracking a specific activity.
93 * @param spanId The span id that represents the activity
94 */
95 private _pushActivity;
96 /**
97 * Remove an activity from usage
98 * @param spanId The span id that represents the activity
99 */
100 private _popActivity;
101 /**
102 * Checks when entries of this.activities are not changing for 3 beats.
103 * If this occurs we finish the transaction.
104 */
105 private _beat;
106 /**
107 * Pings the heartbeat
108 */
109 private _pingHeartbeat;
110}
111//# sourceMappingURL=idletransaction.d.ts.map
\No newline at end of file