forked from getsentry/sentry-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.ts
25 lines (22 loc) · 834 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type { Transaction } from '@sentry/core';
import type { Span, SpanContext } from '@sentry/types';
/**
* Checks if a given value is a valid measurement value.
*/
export function isMeasurementValue(value: unknown): value is number {
return typeof value === 'number' && isFinite(value);
}
/**
* Helper function to start child on transactions. This function will make sure that the transaction will
* use the start timestamp of the created child span if it is earlier than the transactions actual
* start timestamp.
*/
export function _startChild(transaction: Transaction, { startTimestamp, ...ctx }: SpanContext): Span {
if (startTimestamp && transaction.startTimestamp > startTimestamp) {
transaction.startTimestamp = startTimestamp;
}
return transaction.startChild({
startTimestamp,
...ctx,
});
}