Skip to content

Commit ff24d8e

Browse files
committed
dedupe HEARTBEAT_INTERVAL between src and test
1 parent d0e7ad7 commit ff24d8e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/tracing/src/idletransaction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SpanStatus } from './spanstatus';
77
import { Transaction } from './transaction';
88

99
export const DEFAULT_IDLE_TIMEOUT = 1000;
10+
export const HEARTBEAT_INTERVAL = 5000;
1011

1112
/**
1213
* @inheritDoc
@@ -266,7 +267,7 @@ export class IdleTransaction extends Transaction {
266267
logger.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`);
267268
setTimeout(() => {
268269
this._beat();
269-
}, 5000);
270+
}, HEARTBEAT_INTERVAL);
270271
}
271272
}
272273

packages/tracing/test/idletransaction.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { Hub } from '@sentry/hub';
33

4-
import { DEFAULT_IDLE_TIMEOUT, IdleTransaction, IdleTransactionSpanRecorder } from '../src/idletransaction';
4+
import {
5+
DEFAULT_IDLE_TIMEOUT,
6+
HEARTBEAT_INTERVAL,
7+
IdleTransaction,
8+
IdleTransactionSpanRecorder,
9+
} from '../src/idletransaction';
510
import { Span } from '../src/span';
611
import { SpanStatus } from '../src/spanstatus';
712

@@ -177,7 +182,6 @@ describe('IdleTransaction', () => {
177182

178183
describe('heartbeat', () => {
179184
it('does not mark transaction as `DeadlineExceeded` if idle timeout has not been reached', () => {
180-
const HEARTBEAT_INTERVAL = 5000;
181185
// 20s to exceed 3 heartbeats
182186
const transaction = new IdleTransaction({ name: 'foo' }, hub, 20000);
183187
const mockFinish = jest.spyOn(transaction, 'finish');

0 commit comments

Comments
 (0)