UNPKG

4.39 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 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 * Temporary method used to externally set the transaction's `finishReason`
89 *
90 * ** WARNING**
91 * This is for the purpose of experimentation only and will be removed in the near future, do not use!
92 *
93 * @internal
94 *
95 */
96 setFinishReason(reason: string): void;
97 /**
98 * Restarts idle timeout, if there is no running idle timeout it will start one.
99 */
100 private _restartIdleTimeout;
101 /**
102 * Start tracking a specific activity.
103 * @param spanId The span id that represents the activity
104 */
105 private _pushActivity;
106 /**
107 * Remove an activity from usage
108 * @param spanId The span id that represents the activity
109 */
110 private _popActivity;
111 /**
112 * Checks when entries of this.activities are not changing for 3 beats.
113 * If this occurs we finish the transaction.
114 */
115 private _beat;
116 /**
117 * Pings the heartbeat
118 */
119 private _pingHeartbeat;
120}
121//# sourceMappingURL=idletransaction.d.ts.map
\No newline at end of file