Skip to content

Commit f1ed0e9

Browse files
authored
ref: Deprecate extractTraceParentData from @sentry/core & downstream packages (#9158)
Instead, users should import this from `@sentry/utils`. This was also re-exported from all downstream packages (e.g. `@sentry/browser`, `@sentry/node`). I don't think this is something users need to import from there...? If you need this, installing `@sentry/utils` is probably fine.
1 parent 010eb69 commit f1ed0e9

File tree

14 files changed

+33
-14
lines changed

14 files changed

+33
-14
lines changed

MIGRATION.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ 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 `extractTraceParentData` export from `@sentry/core` & downstream packages
12+
13+
Instead, import this directly from `@sentry/utils`.
14+
15+
Generally, in most cases you should probably use `continueTrace` instead, which abstracts this away from you and handles scope propagation for you.
16+
1117
## Deprecate `timestampWithMs` export - #7878
1218

1319
The `timestampWithMs` util is deprecated in favor of using `timestampInSeconds`.

packages/astro/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export {
1616
withMonitor,
1717
configureScope,
1818
createTransport,
19+
// eslint-disable-next-line deprecation/deprecation
1920
extractTraceparentData,
2021
getActiveTransaction,
2122
getHubFromCarrier,

packages/browser/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export type { RequestInstrumentationOptions } from '@sentry-internal/tracing';
4242
export {
4343
addTracingExtensions,
4444
setMeasurement,
45+
// eslint-disable-next-line deprecation/deprecation
4546
extractTraceparentData,
4647
getActiveTransaction,
4748
spanStatusfromHttpCode,

packages/bun/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
close,
3434
configureScope,
3535
createTransport,
36+
// eslint-disable-next-line deprecation/deprecation
3637
extractTraceparentData,
3738
flush,
3839
getActiveTransaction,

packages/core/src/tracing/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export { IdleTransaction, TRACING_DEFAULTS } from './idletransaction';
33
export type { BeforeFinishCallback } from './idletransaction';
44
export { Span, spanStatusfromHttpCode } from './span';
55
export { Transaction } from './transaction';
6+
// eslint-disable-next-line deprecation/deprecation
67
export { extractTraceparentData, getActiveTransaction } from './utils';
78
// eslint-disable-next-line deprecation/deprecation
89
export { SpanStatus } from './spanstatus';

packages/core/src/tracing/utils.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import type { Transaction } from '@sentry/types';
2+
import { extractTraceparentData as _extractTraceparentData } from '@sentry/utils';
23

34
import type { Hub } from '../hub';
45
import { getCurrentHub } from '../hub';
56

7+
/** Grabs active transaction off scope, if any */
8+
export function getActiveTransaction<T extends Transaction>(maybeHub?: Hub): T | undefined {
9+
const hub = maybeHub || getCurrentHub();
10+
const scope = hub.getScope();
11+
return scope.getTransaction() as T | undefined;
12+
}
13+
14+
// so it can be used in manual instrumentation without necessitating a hard dependency on @sentry/utils
15+
export { stripUrlQueryAndFragment } from '@sentry/utils';
16+
617
/**
718
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
819
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
@@ -11,18 +22,8 @@ import { getCurrentHub } from '../hub';
1122
*
1223
* These exports are kept here for backwards compatability's sake.
1324
*
14-
* TODO(v7): Reorganize these exports
15-
*
1625
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
26+
*
27+
* @deprecated Import this function from `@sentry/utils` instead
1728
*/
18-
export { TRACEPARENT_REGEXP, extractTraceparentData } from '@sentry/utils';
19-
20-
/** Grabs active transaction off scope, if any */
21-
export function getActiveTransaction<T extends Transaction>(maybeHub?: Hub): T | undefined {
22-
const hub = maybeHub || getCurrentHub();
23-
const scope = hub.getScope();
24-
return scope.getTransaction() as T | undefined;
25-
}
26-
27-
// so it can be used in manual instrumentation without necessitating a hard dependency on @sentry/utils
28-
export { stripUrlQueryAndFragment } from '@sentry/utils';
29+
export const extractTraceparentData = _extractTraceparentData;

packages/deno/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export {
3131
close,
3232
configureScope,
3333
createTransport,
34+
// eslint-disable-next-line deprecation/deprecation
3435
extractTraceparentData,
36+
continueTrace,
3537
flush,
3638
getActiveTransaction,
3739
getHubFromCarrier,

packages/node-experimental/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export {
3232
close,
3333
configureScope,
3434
createTransport,
35+
// eslint-disable-next-line deprecation/deprecation
3536
extractTraceparentData,
3637
flush,
3738
getActiveTransaction,

packages/node/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
close,
3434
configureScope,
3535
createTransport,
36+
// eslint-disable-next-line deprecation/deprecation
3637
extractTraceparentData,
3738
flush,
3839
getActiveTransaction,

packages/remix/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export {
1919
captureMessage,
2020
configureScope,
2121
createTransport,
22+
// eslint-disable-next-line deprecation/deprecation
2223
extractTraceparentData,
2324
getActiveTransaction,
2425
getHubFromCarrier,

packages/sveltekit/src/server/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
withMonitor,
1515
configureScope,
1616
createTransport,
17+
// eslint-disable-next-line deprecation/deprecation
1718
extractTraceparentData,
1819
getActiveTransaction,
1920
getHubFromCarrier,

packages/tracing-internal/src/exports/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export {
2+
// eslint-disable-next-line deprecation/deprecation
23
extractTraceparentData,
34
getActiveTransaction,
45
hasTracingEnabled,

packages/tracing/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
Postgres,
2121
Prisma,
2222
Span as SpanT,
23-
// eslint-disable-next-line deprecation/deprecation
2423
SpanStatus as SpanStatusT,
2524
spanStatusfromHttpCode as spanStatusfromHttpCodeT,
2625
startIdleTransaction as startIdleTransactionT,
@@ -70,6 +69,7 @@ export const getActiveTransaction = getActiveTransactionT;
7069
*
7170
* `extractTraceparentData` can be imported from `@sentry/node`, `@sentry/browser`, or your framework SDK
7271
*/
72+
// eslint-disable-next-line deprecation/deprecation
7373
export const extractTraceparentData = extractTraceparentDataT;
7474

7575
/**

packages/vercel-edge/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export {
3232
close,
3333
configureScope,
3434
createTransport,
35+
// eslint-disable-next-line deprecation/deprecation
3536
extractTraceparentData,
3637
flush,
3738
getActiveTransaction,

0 commit comments

Comments
 (0)