Skip to content

Commit bb99dfc

Browse files
committed
ref: Use startTransaction where appropriate
1 parent 6e807d4 commit bb99dfc

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

packages/apm/src/integrations/tracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export class Tracing implements Integration {
431431
return undefined;
432432
}
433433

434-
Tracing._activeTransaction = hub.startSpan({
434+
Tracing._activeTransaction = hub.startTransaction({
435435
trimEnd: true,
436436
...transactionContext,
437437
}) as Transaction;

packages/apm/test/hub.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { BrowserClient } from '@sentry/browser';
22
import { Hub, Scope } from '@sentry/hub';
3-
import { Span, Transaction } from '@sentry/types';
43

54
import { addExtensionMethods } from '../src/hubextensions';
65

@@ -21,21 +20,18 @@ describe('Hub', () => {
2120
});
2221
test('set tracesSampleRate 0 on transaction', () => {
2322
const hub = new Hub(new BrowserClient({ tracesSampleRate: 0 }));
24-
// @ts-ignore
25-
const transaction = hub.startSpan({ name: 'foo' }) as any;
23+
const transaction = hub.startTransaction({ name: 'foo' });
2624
expect(transaction.sampled).toBe(false);
2725
});
2826
test('set tracesSampleRate 1 on transaction', () => {
2927
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }));
30-
// @ts-ignore
31-
const transaction = hub.startSpan({ name: 'foo' }) as any;
28+
const transaction = hub.startTransaction({ name: 'foo' });
3229
expect(transaction.sampled).toBeTruthy();
3330
});
3431
test('set tracesSampleRate should be propergated to children', () => {
3532
const hub = new Hub(new BrowserClient({ tracesSampleRate: 0 }));
36-
// @ts-ignore
37-
const transaction = hub.startSpan({ name: 'foo' }) as any;
38-
const child = transaction.startChild({ op: 1 });
33+
const transaction = hub.startTransaction({ name: 'foo' });
34+
const child = transaction.startChild({ op: 'test' });
3935
expect(child.sampled).toBeFalsy();
4036
});
4137
});
@@ -49,8 +45,7 @@ describe('Hub', () => {
4945

5046
test('simple standalone Transaction', () => {
5147
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }));
52-
// @ts-ignore
53-
const transaction = hub.startSpan({ name: 'transaction' }) as Transaction;
48+
const transaction = hub.startTransaction({ name: 'transaction' });
5449
expect(transaction.spanId).toBeTruthy();
5550
// tslint:disable-next-line: no-unbound-method
5651
expect(transaction.setName).toBeTruthy();
@@ -71,8 +66,7 @@ describe('Hub', () => {
7166
test('create a child if there is a Span already on the scope', () => {
7267
const myScope = new Scope();
7368
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }), myScope);
74-
// @ts-ignore
75-
const transaction = hub.startSpan({ name: 'transaction' }) as Transaction;
69+
const transaction = hub.startTransaction({ name: 'transaction' });
7670
hub.configureScope(scope => {
7771
scope.setSpan(transaction);
7872
});

packages/node/test/manual/apm-transaction/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Tracing {
2424
? Span.fromTraceparent(req.headers['sentry-trace'], {
2525
transaction,
2626
})
27-
: Sentry.getCurrentHub().startSpan({
28-
transaction,
27+
: Sentry.startTransaction({
28+
name: transaction,
2929
});
3030

3131
Sentry.getCurrentHub().configureScope(scope => {

0 commit comments

Comments
 (0)