1 | import type { SpanTimeInput, TransactionContext } from '@sentry/types';
|
2 | import type { Hub } from '../hub';
|
3 | import type { Span } from './span';
|
4 | import { SpanRecorder } from './span';
|
5 | import { Transaction } from './transaction';
|
6 | export declare const TRACING_DEFAULTS: {
|
7 | idleTimeout: number;
|
8 | finalTimeout: number;
|
9 | heartbeatInterval: number;
|
10 | };
|
11 | /**
|
12 | * @inheritDoc
|
13 | */
|
14 | export 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 | }
|
24 | export 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 | */
|
30 | export 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 | private _autoFinishAllowed;
|
55 | /**
|
56 | * @deprecated Transactions will be removed in v8. Use spans instead.
|
57 | */
|
58 | constructor(transactionContext: TransactionContext, _idleHub: Hub,
|
59 | /**
|
60 | * The time to wait in ms until the idle transaction will be finished. This timer is started each time
|
61 | * there are no active spans on this transaction.
|
62 | */
|
63 | _idleTimeout?: number,
|
64 | /**
|
65 | * The final value in ms that a transaction cannot exceed
|
66 | */
|
67 | _finalTimeout?: number, _heartbeatInterval?: number, _onScope?: boolean,
|
68 | /**
|
69 | * When set to `true`, will disable the idle timeout (`_idleTimeout` option) and heartbeat mechanisms (`_heartbeatInterval`
|
70 | * option) until the `sendAutoFinishSignal()` method is called. The final timeout mechanism (`_finalTimeout` option)
|
71 | * will not be affected by this option, meaning the transaction will definitely be finished when the final timeout is
|
72 | * reached, no matter what this option is configured to.
|
73 | *
|
74 | * Defaults to `false`.
|
75 | */
|
76 | delayAutoFinishUntilSignal?: boolean);
|
77 | /** {@inheritDoc} */
|
78 | end(endTimestamp?: SpanTimeInput): string | undefined;
|
79 | /**
|
80 | * Register a callback function that gets executed before the transaction finishes.
|
81 | * Useful for cleanup or if you want to add any additional spans based on current context.
|
82 | *
|
83 | * This is exposed because users have no other way of running something before an idle transaction
|
84 | * finishes.
|
85 | */
|
86 | registerBeforeFinishCallback(callback: BeforeFinishCallback): void;
|
87 | /**
|
88 | * @inheritDoc
|
89 | */
|
90 | initSpanRecorder(maxlen?: number): void;
|
91 | /**
|
92 | * Cancels the existing idle timeout, if there is one.
|
93 | * @param restartOnChildSpanChange Default is `true`.
|
94 | * If set to false the transaction will end
|
95 | * with the last child span.
|
96 | */
|
97 | cancelIdleTimeout(endTimestamp?: Parameters<IdleTransaction['end']>[0], { restartOnChildSpanChange, }?: {
|
98 | restartOnChildSpanChange?: boolean;
|
99 | }): void;
|
100 | /**
|
101 | * Temporary method used to externally set the transaction's `finishReason`
|
102 | *
|
103 | * ** WARNING**
|
104 | * This is for the purpose of experimentation only and will be removed in the near future, do not use!
|
105 | *
|
106 | * @internal
|
107 | *
|
108 | */
|
109 | setFinishReason(reason: string): void;
|
110 | /**
|
111 | * Permits the IdleTransaction to automatically end itself via the idle timeout and heartbeat mechanisms when the `delayAutoFinishUntilSignal` option was set to `true`.
|
112 | */
|
113 | sendAutoFinishSignal(): void;
|
114 | /**
|
115 | * Restarts idle timeout, if there is no running idle timeout it will start one.
|
116 | */
|
117 | private _restartIdleTimeout;
|
118 | /**
|
119 | * Start tracking a specific activity.
|
120 | * @param spanId The span id that represents the activity
|
121 | */
|
122 | private _pushActivity;
|
123 | /**
|
124 | * Remove an activity from usage
|
125 | * @param spanId The span id that represents the activity
|
126 | */
|
127 | private _popActivity;
|
128 | /**
|
129 | * Checks when entries of this.activities are not changing for 3 beats.
|
130 | * If this occurs we finish the transaction.
|
131 | */
|
132 | private _beat;
|
133 | /**
|
134 | * Pings the heartbeat
|
135 | */
|
136 | private _pingHeartbeat;
|
137 | }
|
138 | //# sourceMappingURL=idletransaction.d.ts.map |
\ | No newline at end of file |