Skip to content
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

feat(v8/utils): Remove deprecated util functions #11143

Merged
merged 3 commits into from
Mar 18, 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: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Removed top-level exports: `tracingOrigins`, `MetricsAggregator`, `metricsAggreg
`Sentry.configureScope`, `Span`, `spanStatusfromHttpCode`, `makeMain`, `lastEventId`, `pushScope`, `popScope`,
`addGlobalEventProcessor`, `timestampWithMs`, `addExtensionMethods`

Remove util exports: `timestampWithMs`
Removed `@sentry/utils` exports: `timestampWithMs`, `addOrUpdateIntegration`, `tracingContextFromHeaders`, `walk`

- [Deprecation of `Hub` and `getCurrentHub()`](./MIGRATION.md#deprecate-hub)
- [Removal of class-based integrations](./MIGRATION.md#removal-of-class-based-integrations)
Expand Down
1 change: 0 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export * from './clientreport';
export * from './ratelimit';
export * from './baggage';
export * from './url';
export * from './userIntegrations';
export * from './cache';
export * from './eventbuilder';
export * from './anr';
Expand Down
5 changes: 0 additions & 5 deletions packages/utils/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ function visit(
return normalized;
}

/**
* @deprecated This export will be removed in v8.
*/
export { visit as walk };

/* eslint-disable complexity */
/**
* Stringify the given value. Handles various known special values and types.
Expand Down
43 changes: 0 additions & 43 deletions packages/utils/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,6 @@ export function extractTraceparentData(traceparent?: string): TraceparentData |
};
}

/**
* Create tracing context from incoming headers.
*
* @deprecated Use `propagationContextFromHeaders` instead.
*/
// TODO(v8): Remove this function
export function tracingContextFromHeaders(
sentryTrace: Parameters<typeof extractTraceparentData>[0],
baggage: Parameters<typeof baggageHeaderToDynamicSamplingContext>[0],
): {
traceparentData: ReturnType<typeof extractTraceparentData>;
dynamicSamplingContext: ReturnType<typeof baggageHeaderToDynamicSamplingContext>;
propagationContext: PropagationContext;
} {
const traceparentData = extractTraceparentData(sentryTrace);
const dynamicSamplingContext = baggageHeaderToDynamicSamplingContext(baggage);

const { traceId, parentSpanId, parentSampled } = traceparentData || {};

if (!traceparentData) {
return {
traceparentData,
dynamicSamplingContext: undefined,
propagationContext: {
traceId: traceId || uuid4(),
spanId: uuid4().substring(16),
},
};
} else {
return {
traceparentData,
dynamicSamplingContext: dynamicSamplingContext || {}, // If we have traceparent data but no DSC it means we are not head of trace and we must freeze it
propagationContext: {
traceId: traceId || uuid4(),
parentSpanId: parentSpanId || uuid4().substring(16),
spanId: uuid4().substring(16),
sampled: parentSampled,
dsc: dynamicSamplingContext || {}, // If we have traceparent data but no DSC it means we are not head of trace and we must freeze it
},
};
}
}

/**
* Create a propagation context from incoming headers.
*/
Expand Down
115 changes: 0 additions & 115 deletions packages/utils/src/userIntegrations.ts

This file was deleted.

11 changes: 1 addition & 10 deletions packages/utils/test/tracing.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { extractTraceparentData, propagationContextFromHeaders, tracingContextFromHeaders } from '../src/tracing';
import { extractTraceparentData, propagationContextFromHeaders } from '../src/tracing';

const EXAMPLE_SENTRY_TRACE = '12312012123120121231201212312012-1121201211212012-1';
const EXAMPLE_BAGGAGE = 'sentry-release=1.2.3,sentry-foo=bar,other=baz';

describe('tracingContextFromHeaders()', () => {
it('should produce a frozen baggage (empty object) when there is an incoming trace but no baggage header', () => {
// eslint-disable-next-line deprecation/deprecation
const tracingContext = tracingContextFromHeaders('12312012123120121231201212312012-1121201211212012-1', undefined);
expect(tracingContext.dynamicSamplingContext).toEqual({});
expect(tracingContext.propagationContext.dsc).toEqual({});
});
});

describe('propagationContextFromHeaders()', () => {
it('returns a completely new propagation context when no sentry-trace data is given but baggage data is given', () => {
const result = propagationContextFromHeaders(undefined, undefined);
Expand Down
Loading
Loading