From 72b97421b5e7eff0bcdf3407c972e4c890dd62af Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 25 Mar 2024 20:29:09 -0400 Subject: [PATCH] feat(core/v8): Remove _frozenDynamicSamplingContext --- .../rollup-utils/plugins/bundlePlugins.mjs | 3 -- .../src/tracing/dynamicSamplingContext.ts | 32 ++++--------------- packages/core/src/tracing/transaction.ts | 11 ------- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs index 80dbc4422ea4..bb0b371fd515 100644 --- a/dev-packages/rollup-utils/plugins/bundlePlugins.mjs +++ b/dev-packages/rollup-utils/plugins/bundlePlugins.mjs @@ -121,9 +121,6 @@ export function makeTerserPlugin() { // These are used by instrument.ts in utils for identifying HTML elements & events '_sentryCaptured', '_sentryId', - // For v7 backwards-compatibility we need to access txn._frozenDynamicSamplingContext - // TODO (v8): Remove this reserved word - '_frozenDynamicSamplingContext', // These are used to keep span relationships '_sentryRootSpan', '_sentryChildSpans', diff --git a/packages/core/src/tracing/dynamicSamplingContext.ts b/packages/core/src/tracing/dynamicSamplingContext.ts index 04510683a1b9..12b27d964135 100644 --- a/packages/core/src/tracing/dynamicSamplingContext.ts +++ b/packages/core/src/tracing/dynamicSamplingContext.ts @@ -1,9 +1,9 @@ -import type { Client, DynamicSamplingContext, Span, Transaction } from '@sentry/types'; +import type { Client, DynamicSamplingContext, Span } from '@sentry/types'; import { dropUndefinedKeys } from '@sentry/utils'; import { DEFAULT_ENVIRONMENT } from '../constants'; import { getClient } from '../currentScopes'; -import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes'; +import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes'; import { getRootSpan, spanIsSampled, spanToJSON } from '../utils/spanUtils'; /** @@ -28,11 +28,6 @@ export function getDynamicSamplingContextFromClient(trace_id: string, client: Cl return dsc; } -/** - * A Span with a frozen dynamic sampling context. - */ -type TransactionWithV7FrozenDsc = Transaction & { _frozenDynamicSamplingContext?: DynamicSamplingContext }; - /** * Creates a dynamic sampling context from a span (and client and scope) * @@ -47,34 +42,21 @@ export function getDynamicSamplingContextFromSpan(span: Span): Readonly> | undefined; - private _metadata: Partial; /** @@ -78,14 +75,6 @@ export class Transaction extends SentrySpan implements TransactionInterface { // TODO (v8): Replace this with another way to set the root span // eslint-disable-next-line deprecation/deprecation this.transaction = this; - - // If Dynamic Sampling Context is provided during the creation of the transaction, we freeze it as it usually means - // there is incoming Dynamic Sampling Context. (Either through an incoming request, a baggage meta-tag, or other means) - const incomingDynamicSamplingContext = this._metadata.dynamicSamplingContext; - if (incomingDynamicSamplingContext) { - // We shallow copy this in case anything writes to the original reference of the passed in `dynamicSamplingContext` - this._frozenDynamicSamplingContext = { ...incomingDynamicSamplingContext }; - } } // This sadly conflicts with the getter/setter ordering :(