Skip to content

Commit 2e6f903

Browse files
authored
ref(v8): Remove deprecated scope.getTransaction() (#11365)
This depends on #11363 being merged first...
1 parent cc0599f commit 2e6f903

File tree

4 files changed

+12
-35
lines changed

4 files changed

+12
-35
lines changed

dev-packages/node-integration-tests/suites/tracing/metric-summaries/test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const EXPECTED_TRANSACTION = {
1111
sum: 1,
1212
tags: {
1313
release: '1.0',
14+
transaction: 'Test Transaction',
1415
1516
},
1617
},
@@ -21,6 +22,7 @@ const EXPECTED_TRANSACTION = {
2122
sum: 1,
2223
tags: {
2324
release: '1.0',
25+
transaction: 'Test Transaction',
2426
2527
},
2628
},
@@ -39,6 +41,7 @@ const EXPECTED_TRANSACTION = {
3941
sum: 4,
4042
tags: {
4143
release: '1.0',
44+
transaction: 'Test Transaction',
4245
},
4346
},
4447
],
@@ -50,6 +53,7 @@ const EXPECTED_TRANSACTION = {
5053
sum: 2,
5154
tags: {
5255
release: '1.0',
56+
transaction: 'Test Transaction',
5357
},
5458
},
5559
],
@@ -61,6 +65,7 @@ const EXPECTED_TRANSACTION = {
6165
sum: 62,
6266
tags: {
6367
release: '1.0',
68+
transaction: 'Test Transaction',
6469
},
6570
},
6671
],
@@ -72,6 +77,7 @@ const EXPECTED_TRANSACTION = {
7277
sum: 62,
7378
tags: {
7479
release: '1.0',
80+
transaction: 'Test Transaction',
7581
},
7682
},
7783
],

packages/core/src/metrics/exports.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import type {
55
Primitive,
66
} from '@sentry/types';
77
import { getGlobalSingleton, logger } from '@sentry/utils';
8-
import { getCurrentScope } from '../currentScopes';
98
import { getClient } from '../currentScopes';
109
import { DEBUG_BUILD } from '../debug-build';
11-
import { spanToJSON } from '../utils/spanUtils';
10+
import { getActiveSpan, getRootSpan, spanToJSON } from '../utils/spanUtils';
1211
import { COUNTER_METRIC_TYPE, DISTRIBUTION_METRIC_TYPE, GAUGE_METRIC_TYPE, SET_METRIC_TYPE } from './constants';
1312
import type { MetricType } from './types';
1413

@@ -63,20 +62,20 @@ function addToMetricsAggregator(
6362
return;
6463
}
6564

66-
const scope = getCurrentScope();
65+
const span = getActiveSpan();
66+
const rootSpan = span ? getRootSpan(span) : undefined;
67+
6768
const { unit, tags, timestamp } = data;
6869
const { release, environment } = client.getOptions();
69-
// eslint-disable-next-line deprecation/deprecation
70-
const transaction = scope.getTransaction();
7170
const metricTags: Record<string, string> = {};
7271
if (release) {
7372
metricTags.release = release;
7473
}
7574
if (environment) {
7675
metricTags.environment = environment;
7776
}
78-
if (transaction) {
79-
metricTags.transaction = spanToJSON(transaction).description || '';
77+
if (rootSpan) {
78+
metricTags.transaction = spanToJSON(rootSpan).description || '';
8079
}
8180

8281
DEBUG_BUILD && logger.log(`Adding value of ${value} to ${metricType} metric ${name}`);

packages/core/src/scope.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ import type {
1919
ScopeData,
2020
Session,
2121
SeverityLevel,
22-
Transaction,
2322
User,
2423
} from '@sentry/types';
2524
import { dateTimestampInSeconds, isPlainObject, logger, uuid4 } from '@sentry/utils';
2625

2726
import { updateSession } from './session';
28-
import type { SentrySpan } from './tracing/sentrySpan';
2927
import { _getSpanForScope, _setSpanForScope } from './utils/spanOnScope';
3028

3129
/**
@@ -294,25 +292,6 @@ export class Scope implements ScopeInterface {
294292
return this;
295293
}
296294

297-
/**
298-
* Returns the `Transaction` attached to the scope (if there is one).
299-
* @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
300-
*/
301-
public getTransaction(): Transaction | undefined {
302-
// Often, this span (if it exists at all) will be a transaction, but it's not guaranteed to be. Regardless, it will
303-
// have a pointer to the currently-active transaction.
304-
const span = _getSpanForScope(this);
305-
306-
// Cannot replace with getRootSpan because getRootSpan returns a span, not a transaction
307-
// Also, this method will be removed anyway.
308-
// eslint-disable-next-line deprecation/deprecation
309-
if (span && (span as SentrySpan).transaction) {
310-
// eslint-disable-next-line deprecation/deprecation
311-
return (span as SentrySpan).transaction;
312-
}
313-
return undefined;
314-
}
315-
316295
/**
317296
* @inheritDoc
318297
*/

packages/types/src/scope.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { RequestSession, Session } from './session';
1010
import type { SeverityLevel } from './severity';
1111
import type { Span } from './span';
1212
import type { PropagationContext } from './tracing';
13-
import type { Transaction } from './transaction';
1413
import type { User } from './user';
1514

1615
/** JSDocs */
@@ -145,12 +144,6 @@ export interface Scope {
145144
*/
146145
setContext(name: string, context: Context | null): this;
147146

148-
/**
149-
* Returns the `Transaction` attached to the scope (if there is one).
150-
* @deprecated You should not rely on the transaction, but just use `startSpan()` APIs instead.
151-
*/
152-
getTransaction(): Transaction | undefined;
153-
154147
/**
155148
* Returns the `Session` if there is one
156149
*/

0 commit comments

Comments
 (0)