Skip to content

Commit e9ce479

Browse files
committed
port startTransaction
1 parent 97d161a commit e9ce479

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

packages/hub/src/exports.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import {
22
Breadcrumb,
33
CaptureContext,
4+
CustomSamplingContext,
45
Event,
56
Extra,
67
Extras,
78
Primitive,
89
Severity,
910
SeverityLevel,
11+
TransactionContext,
1012
User,
1113
} from '@sentry/types';
1214

@@ -160,3 +162,27 @@ export function setUser(user: User | null): ReturnType<Hub['setUser']> {
160162
export function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {
161163
getCurrentHub().withScope(callback);
162164
}
165+
166+
/**
167+
* Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.
168+
*
169+
* A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
170+
* new child span within the transaction or any span, call the respective `.startChild()` method.
171+
*
172+
* Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
173+
*
174+
* The transaction must be finished with a call to its `.finish()` method, at which point the transaction with all its
175+
* finished child spans will be sent to Sentry.
176+
*
177+
* @param context Properties of the new `Transaction`.
178+
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
179+
* default values). See {@link Options.tracesSampler}.
180+
*
181+
* @returns The transaction which was just started
182+
*/
183+
export function startTransaction(
184+
context: TransactionContext,
185+
customSamplingContext?: CustomSamplingContext,
186+
): ReturnType<Hub['startTransaction']> {
187+
return getCurrentHub().startTransaction({ ...context }, customSamplingContext);
188+
}

packages/minimal/src/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,3 @@ function callOnHub<T>(method: string, ...args: any[]): T {
2828
}
2929
throw new Error(`No hub defined or ${method} was not found on the hub, please open a bug report.`);
3030
}
31-
32-
/**
33-
* Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.
34-
*
35-
* A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
36-
* new child span within the transaction or any span, call the respective `.startChild()` method.
37-
*
38-
* Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
39-
*
40-
* The transaction must be finished with a call to its `.finish()` method, at which point the transaction with all its
41-
* finished child spans will be sent to Sentry.
42-
*
43-
* @param context Properties of the new `Transaction`.
44-
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
45-
* default values). See {@link Options.tracesSampler}.
46-
*
47-
* @returns The transaction which was just started
48-
*/
49-
export function startTransaction(
50-
context: TransactionContext,
51-
customSamplingContext?: CustomSamplingContext,
52-
): Transaction {
53-
return callOnHub('startTransaction', { ...context }, customSamplingContext);
54-
}

0 commit comments

Comments
 (0)