Skip to content

Commit d712fa0

Browse files
committed
ref(v8): Remove deprecated scope.getTransaction()
1 parent 4451405 commit d712fa0

File tree

3 files changed

+6
-35
lines changed

3 files changed

+6
-35
lines changed

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
/**
@@ -302,25 +300,6 @@ export class Scope implements ScopeInterface {
302300
return this;
303301
}
304302

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

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)