Skip to content

Commit f70128d

Browse files
authored
feat(core): Deprecate scope.getSpan() & scope.setSpan() (#10114)
These APIs are not compatible with OTEL tracing, and thus will not be public API anymore in v8. In v8, we'll add new (?) methods to the scope that are "internal", as for non-node based SDKs we'll still need to keep the active span on the scope. But these should not be reflected publicly, and not in types' Scope. Note that we'll also need to make sure to use types' `Scope` for all callbacks etc., which we currently don't do.
1 parent d41e39e commit f70128d

File tree

47 files changed

+150
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+150
-44
lines changed

MIGRATION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ npx @sentry/migr8@latest
88

99
This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!
1010

11+
## Deprecate `scope.getSpan()` and `scope.setSpan()`
12+
13+
Instead, you can get the currently active span via `Sentry.getActiveSpan()`.
14+
Setting a span on the scope happens automatically when you use the new performance APIs `startSpan()` and `startSpanManual()`.
15+
1116
## Deprecate `scope.setTransactionName()`
1217

1318
Instead, either set this as attributes or tags, or use an event processor to set `event.transaction`.

dev-packages/e2e-tests/test-applications/create-next-app/pages/api/success.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';
55
export default function handler(req: NextApiRequest, res: NextApiResponse) {
66
// eslint-disable-next-line deprecation/deprecation
77
const transaction = Sentry.startTransaction({ name: 'test-transaction', op: 'e2e-test' });
8+
// eslint-disable-next-line deprecation/deprecation
89
Sentry.getCurrentHub().getScope().setSpan(transaction);
910

1011
// eslint-disable-next-line deprecation/deprecation

dev-packages/node-integration-tests/suites/tracing-new/apollo-graphql/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const server = new ApolloServer({
3030
// eslint-disable-next-line deprecation/deprecation
3131
const transaction = Sentry.startTransaction({ name: 'test_transaction', op: 'transaction' });
3232

33+
// eslint-disable-next-line deprecation/deprecation
3334
Sentry.getCurrentScope().setSpan(transaction);
3435

3536
// eslint-disable-next-line @typescript-eslint/no-floating-promises

dev-packages/node-integration-tests/suites/tracing-new/auto-instrument/mongodb/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ async function run(): Promise<void> {
2222
op: 'transaction',
2323
});
2424

25+
// eslint-disable-next-line deprecation/deprecation
2526
Sentry.getCurrentScope().setSpan(transaction);
2627

2728
try {

dev-packages/node-integration-tests/suites/tracing-new/auto-instrument/mysql/withConnect/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const transaction = Sentry.startTransaction({
2525
name: 'Test Transaction',
2626
});
2727

28+
// eslint-disable-next-line deprecation/deprecation
2829
Sentry.getCurrentScope().setSpan(transaction);
2930

3031
connection.query('SELECT 1 + 1 AS solution', function () {

dev-packages/node-integration-tests/suites/tracing-new/auto-instrument/mysql/withoutCallback/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const transaction = Sentry.startTransaction({
2525
name: 'Test Transaction',
2626
});
2727

28+
// eslint-disable-next-line deprecation/deprecation
2829
Sentry.getCurrentScope().setSpan(transaction);
2930

3031
const query = connection.query('SELECT 1 + 1 AS solution');

dev-packages/node-integration-tests/suites/tracing-new/auto-instrument/mysql/withoutConnect/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const transaction = Sentry.startTransaction({
1919
name: 'Test Transaction',
2020
});
2121

22+
// eslint-disable-next-line deprecation/deprecation
2223
Sentry.getCurrentScope().setSpan(transaction);
2324

2425
connection.query('SELECT 1 + 1 AS solution', function () {

dev-packages/node-integration-tests/suites/tracing-new/auto-instrument/pg/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const transaction = Sentry.startTransaction({
1414
name: 'Test Transaction',
1515
});
1616

17+
// eslint-disable-next-line deprecation/deprecation
1718
Sentry.getCurrentScope().setSpan(transaction);
1819

1920
const client = new pg.Client();

dev-packages/node-integration-tests/suites/tracing-new/prisma-orm/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async function run(): Promise<void> {
1919
op: 'transaction',
2020
});
2121

22+
// eslint-disable-next-line deprecation/deprecation
2223
Sentry.getCurrentScope().setSpan(transaction);
2324

2425
try {

dev-packages/node-integration-tests/suites/tracing-new/tracePropagationTargets/scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Sentry.init({
1313
// eslint-disable-next-line deprecation/deprecation
1414
const transaction = Sentry.startTransaction({ name: 'test_transaction' });
1515

16+
// eslint-disable-next-line deprecation/deprecation
1617
Sentry.getCurrentScope().setSpan(transaction);
1718

1819
http.get('http://match-this-url.com/api/v0');

0 commit comments

Comments
 (0)