Skip to content

Commit eb5bb3d

Browse files
authored
feat(core): Deprecate new Transaction() (#10125)
No more transaction class! This should not really affect users, as they should only use `startTransaction()` anyhow.
1 parent a56fc29 commit eb5bb3d

File tree

10 files changed

+22
-0
lines changed

10 files changed

+22
-0
lines changed

packages/core/src/tracing/hubextensions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The transaction will not be sampled. Please use the ${configInstrumenter} instru
6060
transactionContext.sampled = false;
6161
}
6262

63+
// eslint-disable-next-line deprecation/deprecation
6364
let transaction = new Transaction(transactionContext, this);
6465
transaction = sampleTransaction(transaction, options, {
6566
parentSampled: transactionContext.parentSampled,
@@ -90,6 +91,7 @@ export function startIdleTransaction(
9091
const client = hub.getClient();
9192
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
9293

94+
// eslint-disable-next-line deprecation/deprecation
9395
let transaction = new IdleTransaction(transactionContext, hub, idleTimeout, finalTimeout, heartbeatInterval, onScope);
9496
transaction = sampleTransaction(transaction, options, {
9597
parentSampled: transactionContext.parentSampled,

packages/core/src/tracing/idletransaction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export class IdleTransaction extends Transaction {
9595

9696
private _finishReason: (typeof IDLE_TRANSACTION_FINISH_REASONS)[number];
9797

98+
/**
99+
* @deprecated Transactions will be removed in v8. Use spans instead.
100+
*/
98101
public constructor(
99102
transactionContext: TransactionContext,
100103
private readonly _idleHub: Hub,

packages/core/src/tracing/transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class Transaction extends SpanClass implements TransactionInterface {
4545
* @internal
4646
* @hideconstructor
4747
* @hidden
48+
*
49+
* @deprecated Transactions will be removed in v8. Use spans instead.
4850
*/
4951
public constructor(transactionContext: TransactionContext, hub?: Hub) {
5052
super(transactionContext);

packages/node/test/handlers.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ describe('tracingHandler', () => {
361361
});
362362

363363
it('pulls status code from the response', done => {
364+
// eslint-disable-next-line deprecation/deprecation
364365
const transaction = new Transaction({ name: 'mockTransaction' });
365366
jest.spyOn(sentryCore, 'startTransaction').mockReturnValue(transaction as Transaction);
366367
const finishTransaction = jest.spyOn(transaction, 'end');
@@ -412,6 +413,7 @@ describe('tracingHandler', () => {
412413
});
413414

414415
it('closes the transaction when request processing is done', done => {
416+
// eslint-disable-next-line deprecation/deprecation
415417
const transaction = new Transaction({ name: 'mockTransaction' });
416418
jest.spyOn(sentryCore, 'startTransaction').mockReturnValue(transaction as Transaction);
417419
const finishTransaction = jest.spyOn(transaction, 'end');
@@ -426,6 +428,7 @@ describe('tracingHandler', () => {
426428
});
427429

428430
it('waits to finish transaction until all spans are finished, even though `transaction.end()` is registered on `res.finish` event first', done => {
431+
// eslint-disable-next-line deprecation/deprecation
429432
const transaction = new Transaction({ name: 'mockTransaction', sampled: true });
430433
transaction.initSpanRecorder();
431434
// eslint-disable-next-line deprecation/deprecation

packages/opentelemetry-node/test/propagator.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('SentryPropagator', () => {
6060
}
6161

6262
function createTransactionAndMaybeSpan(type: PerfType, transactionContext: TransactionContext) {
63+
// eslint-disable-next-line deprecation/deprecation
6364
const transaction = new Transaction(transactionContext, hub);
6465
setSentrySpan(transaction.spanContext().spanId, transaction);
6566
if (type === PerfType.Span) {

packages/opentelemetry/src/custom/transaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export function startTransaction(hub: HubInterface, transactionContext: Transact
1111
const client = hub.getClient();
1212
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
1313

14+
// eslint-disable-next-line deprecation/deprecation
1415
const transaction = new OpenTelemetryTransaction(transactionContext, hub as Hub);
1516
// Since we do not do sampling here, we assume that this is _always_ sampled
1617
// Any sampling decision happens in OpenTelemetry's sampler

packages/opentelemetry/test/custom/transaction.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('NodeExperimentalTransaction', () => {
1717
const hub = getCurrentHub();
1818
hub.bindClient(client);
1919

20+
// eslint-disable-next-line deprecation/deprecation
2021
const transaction = new OpenTelemetryTransaction({ name: 'test', sampled: true }, hub);
2122

2223
const res = transaction.finishWithScope();
@@ -63,6 +64,7 @@ describe('NodeExperimentalTransaction', () => {
6364
const hub = getCurrentHub();
6465
hub.bindClient(client);
6566

67+
// eslint-disable-next-line deprecation/deprecation
6668
const transaction = new OpenTelemetryTransaction({ name: 'test', startTimestamp: 123456, sampled: true }, hub);
6769

6870
const res = transaction.finishWithScope(1234567);
@@ -87,6 +89,7 @@ describe('NodeExperimentalTransaction', () => {
8789
const hub = getCurrentHub();
8890
hub.bindClient(client);
8991

92+
// eslint-disable-next-line deprecation/deprecation
9093
const transaction = new OpenTelemetryTransaction({ name: 'test', startTimestamp: 123456, sampled: true }, hub);
9194

9295
const scope = new OpenTelemetryScope();

packages/tracing-internal/test/browser/metrics/index.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ResourceEntry } from '../../../src/browser/metrics';
33
import { _addMeasureSpans, _addResourceSpans } from '../../../src/browser/metrics';
44

55
describe('_addMeasureSpans', () => {
6+
// eslint-disable-next-line deprecation/deprecation
67
const transaction = new Transaction({ op: 'pageload', name: '/' });
78
beforeEach(() => {
89
// eslint-disable-next-line deprecation/deprecation
@@ -39,6 +40,7 @@ describe('_addMeasureSpans', () => {
3940
});
4041

4142
describe('_addResourceSpans', () => {
43+
// eslint-disable-next-line deprecation/deprecation
4244
const transaction = new Transaction({ op: 'pageload', name: '/' });
4345
beforeEach(() => {
4446
// eslint-disable-next-line deprecation/deprecation

packages/tracing-internal/test/browser/metrics/utils.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { _startChild } from '../../../src/browser/metrics/utils';
44

55
describe('_startChild()', () => {
66
it('creates a span with given properties', () => {
7+
// eslint-disable-next-line deprecation/deprecation
78
const transaction = new Transaction({ name: 'test' });
89
const span = _startChild(transaction, {
910
description: 'evaluation',
@@ -16,6 +17,7 @@ describe('_startChild()', () => {
1617
});
1718

1819
it('adjusts the start timestamp if child span starts before transaction', () => {
20+
// eslint-disable-next-line deprecation/deprecation
1921
const transaction = new Transaction({ name: 'test', startTimestamp: 123 });
2022
const span = _startChild(transaction, {
2123
description: 'script.js',
@@ -28,6 +30,7 @@ describe('_startChild()', () => {
2830
});
2931

3032
it('does not adjust start timestamp if child span starts after transaction', () => {
33+
// eslint-disable-next-line deprecation/deprecation
3134
const transaction = new Transaction({ name: 'test', startTimestamp: 123 });
3235
const span = _startChild(transaction, {
3336
description: 'script.js',

packages/tracing/test/idletransaction.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable deprecation/deprecation */
12
import { BrowserClient } from '@sentry/browser';
23
import {
34
TRACING_DEFAULTS,
@@ -96,6 +97,7 @@ describe('IdleTransaction', () => {
9697
transaction.initSpanRecorder(10);
9798

9899
// @ts-expect-error need to pass in hub
100+
// eslint-disable-next-line deprecation/deprecation
99101
const otherTransaction = new Transaction({ name: 'bar' }, hub);
100102
// eslint-disable-next-line deprecation/deprecation
101103
hub.getScope().setSpan(otherTransaction);

0 commit comments

Comments
 (0)