Skip to content

feat(v8): Remove extractTraceparentData export #10559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export {
addTracingExtensions,
setMeasurement,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
getSpanStatusFromHttpCode,
setHttpStatus,
Expand Down
2 changes: 0 additions & 2 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export {
captureMessage,
close,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
flush,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type { BeforeFinishCallback } from './idletransaction';
export { Span } from './span';
export { Transaction } from './transaction';
// eslint-disable-next-line deprecation/deprecation
export { extractTraceparentData, getActiveTransaction } from './utils';
export { getActiveTransaction } from './utils';
// eslint-disable-next-line deprecation/deprecation
export { SpanStatus } from './spanstatus';
export {
Expand Down
15 changes: 0 additions & 15 deletions packages/core/src/tracing/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Transaction } from '@sentry/types';
import { extractTraceparentData as _extractTraceparentData } from '@sentry/utils';

import type { Hub } from '../hub';
import { getCurrentHub } from '../hub';
Expand All @@ -20,17 +19,3 @@ export function getActiveTransaction<T extends Transaction>(maybeHub?: Hub): T |

// so it can be used in manual instrumentation without necessitating a hard dependency on @sentry/utils
export { stripUrlQueryAndFragment } from '@sentry/utils';

/**
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
* to be declared in this file. It was later moved into `@sentry/utils` as part of a
* move to remove `@sentry/tracing` dependencies from `@sentry/node` (`extractTraceparentData`
* is the only tracing function used by `@sentry/node`).
*
* These exports are kept here for backwards compatability's sake.
*
* See https://github.com/getsentry/sentry-javascript/issues/4642 for more details.
*
* @deprecated Import this function from `@sentry/utils` instead
*/
export const extractTraceparentData = _extractTraceparentData;
2 changes: 0 additions & 2 deletions packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export {
captureMessage,
close,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
continueTrace,
flush,
// eslint-disable-next-line deprecation/deprecation
Expand Down
2 changes: 0 additions & 2 deletions packages/node-experimental/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export {
createGetModuleFromFilename,
close,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
flush,
Hub,
runWithAsyncContext,
Expand Down
2 changes: 0 additions & 2 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export {
captureMessage,
close,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
flush,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
Expand Down
2 changes: 0 additions & 2 deletions packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export {
captureMessage,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
getHubFromCarrier,
// eslint-disable-next-line deprecation/deprecation
Expand Down
2 changes: 0 additions & 2 deletions packages/serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export {
getModuleFromFilename,
createGetModuleFromFilename,
metrics,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
runWithAsyncContext,
consoleIntegration,
onUncaughtExceptionIntegration,
Expand Down
2 changes: 0 additions & 2 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export {
withMonitor,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
getHubFromCarrier,
// eslint-disable-next-line deprecation/deprecation
Expand Down
2 changes: 0 additions & 2 deletions packages/tracing-internal/src/exports/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export {
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
hasTracingEnabled,
Expand Down
9 changes: 0 additions & 9 deletions packages/tracing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
Transaction as TransactionT,
addExtensionMethods as addExtensionMethodsT,
defaultRequestInstrumentationOptions as defaultRequestInstrumentationOptionsT,
extractTraceparentData as extractTraceparentDataT,
getActiveTransaction as getActiveTransactionT,
hasTracingEnabled as hasTracingEnabledT,
instrumentOutgoingRequests as instrumentOutgoingRequestsT,
Expand Down Expand Up @@ -66,14 +65,6 @@ export const addExtensionMethods = addExtensionMethodsT;
// eslint-disable-next-line deprecation/deprecation
export const getActiveTransaction = getActiveTransactionT;

/**
* @deprecated `@sentry/tracing` has been deprecated and will be moved to to `@sentry/node`, `@sentry/browser`, or your framework SDK in the next major version.
*
* `extractTraceparentData` can be imported from `@sentry/node`, `@sentry/browser`, or your framework SDK
*/
// eslint-disable-next-line deprecation/deprecation
export const extractTraceparentData = extractTraceparentDataT;

/**
* @deprecated `@sentry/tracing` has been deprecated and will be moved to to `@sentry/node`, `@sentry/browser`, or your framework SDK in the next major version.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing/test/hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { BrowserClient } from '@sentry/browser';
import { Hub, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, makeMain } from '@sentry/core';
import * as utilsModule from '@sentry/utils'; // for mocking
import { logger } from '@sentry/utils';
import { extractTraceparentData, logger } from '@sentry/utils';

import { BrowserTracing, TRACEPARENT_REGEXP, Transaction, addExtensionMethods, extractTraceparentData } from '../src';
import { BrowserTracing, TRACEPARENT_REGEXP, Transaction, addExtensionMethods } from '../src';
import {
addDOMPropertiesToGlobal,
getDefaultBrowserClientOptions,
Expand Down
71 changes: 1 addition & 70 deletions packages/tracing/test/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable deprecation/deprecation */
import { extractTraceparentData, hasTracingEnabled } from '../src';
import { hasTracingEnabled } from '../src';

describe('hasTracingEnabled (deprecated)', () => {
const tracesSampler = () => 1;
Expand Down Expand Up @@ -33,72 +33,3 @@ describe('hasTracingEnabled (deprecated)', () => {
},
);
});

describe('extractTraceparentData', () => {
test('no sample', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb') as any;

expect(data).toBeDefined();
expect(data.parentSpanId).toEqual('bbbbbbbbbbbbbbbb');
expect(data.traceId).toEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
expect(data?.parentSampled).toBeUndefined();
});

test('sample true', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-1') as any;

expect(data).toBeDefined();
expect(data.parentSampled).toBeTruthy();
});

test('sample false', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-0') as any;

expect(data).toBeDefined();
expect(data.parentSampled).toBeFalsy();
});

test('just sample decision - false', () => {
const data = extractTraceparentData('0') as any;

expect(data).toBeDefined();
expect(data.traceId).toBeUndefined();
expect(data.spanId).toBeUndefined();
expect(data.parentSampled).toBeFalsy();
});

test('just sample decision - true', () => {
const data = extractTraceparentData('1') as any;

expect(data).toBeDefined();
expect(data.traceId).toBeUndefined();
expect(data.spanId).toBeUndefined();
expect(data.parentSampled).toBeTruthy();
});

test('invalid', () => {
// undefined
expect(extractTraceparentData(undefined)).toBeUndefined();

// empty string
expect(extractTraceparentData('')).toBeUndefined();

// trace id wrong length
expect(extractTraceparentData('a-bbbbbbbbbbbbbbbb-1')).toBeUndefined();

// parent span id wrong length
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b-1')).toBeUndefined();

// parent sampling decision wrong length
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-11')).toBeUndefined();

// trace id invalid hex value
expect(extractTraceparentData('someStuffHereWhichIsNotAtAllHexy-bbbbbbbbbbbbbbbb-1')).toBeUndefined();

// parent span id invalid hex value
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-alsoNotSuperHexy-1')).toBeUndefined();

// bogus sampling decision
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-x')).toBeUndefined();
});
});
71 changes: 70 additions & 1 deletion packages/utils/test/tracing.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { propagationContextFromHeaders, tracingContextFromHeaders } from '../src/tracing';
import { extractTraceparentData, propagationContextFromHeaders, tracingContextFromHeaders } from '../src/tracing';

const EXAMPLE_SENTRY_TRACE = '12312012123120121231201212312012-1121201211212012-1';
const EXAMPLE_BAGGAGE = 'sentry-release=1.2.3,sentry-foo=bar,other=baz';
Expand Down Expand Up @@ -64,3 +64,72 @@ describe('propagationContextFromHeaders()', () => {
});
});
});

describe('extractTraceparentData', () => {
test('no sample', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb') as any;

expect(data).toBeDefined();
expect(data.parentSpanId).toEqual('bbbbbbbbbbbbbbbb');
expect(data.traceId).toEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
expect(data?.parentSampled).toBeUndefined();
});

test('sample true', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-1') as any;

expect(data).toBeDefined();
expect(data.parentSampled).toBeTruthy();
});

test('sample false', () => {
const data = extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-0') as any;

expect(data).toBeDefined();
expect(data.parentSampled).toBeFalsy();
});

test('just sample decision - false', () => {
const data = extractTraceparentData('0') as any;

expect(data).toBeDefined();
expect(data.traceId).toBeUndefined();
expect(data.spanId).toBeUndefined();
expect(data.parentSampled).toBeFalsy();
});

test('just sample decision - true', () => {
const data = extractTraceparentData('1') as any;

expect(data).toBeDefined();
expect(data.traceId).toBeUndefined();
expect(data.spanId).toBeUndefined();
expect(data.parentSampled).toBeTruthy();
});

test('invalid', () => {
// undefined
expect(extractTraceparentData(undefined)).toBeUndefined();

// empty string
expect(extractTraceparentData('')).toBeUndefined();

// trace id wrong length
expect(extractTraceparentData('a-bbbbbbbbbbbbbbbb-1')).toBeUndefined();

// parent span id wrong length
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b-1')).toBeUndefined();

// parent sampling decision wrong length
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-11')).toBeUndefined();

// trace id invalid hex value
expect(extractTraceparentData('someStuffHereWhichIsNotAtAllHexy-bbbbbbbbbbbbbbbb-1')).toBeUndefined();

// parent span id invalid hex value
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-alsoNotSuperHexy-1')).toBeUndefined();

// bogus sampling decision
expect(extractTraceparentData('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-x')).toBeUndefined();
});
});
2 changes: 0 additions & 2 deletions packages/vercel-edge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export {
captureMessage,
close,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
flush,
// eslint-disable-next-line deprecation/deprecation
getActiveTransaction,
Expand Down