Skip to content

feat(core)!: Remove transactionContext from samplingContext #14904

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 5 commits into from
Jan 13, 2025
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
1 change: 1 addition & 0 deletions docs/migration/v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Since v9, the types have been merged into `@sentry/core`, which removed some of
- The `Request` type has been removed. Use `RequestEventData` type instead.
- The `IntegrationClass` type is no longer exported - it was not used anymore. Instead, use `Integration` or `IntegrationFn`.
- The `samplingContext.request` attribute in the `tracesSampler` has been removed. Use `samplingContext.normalizedRequest` instead. Note that the type of `normalizedRequest` differs from `request`.
- The `samplingContext.transactionContext` object in the `tracesSampler` has been removed. All object attributes are available in the top-level of `samplingContext`.
- `Client` now always expects the `BaseClient` class - there is no more abstract `Client` that can be implemented! Any `Client` class has to extend from `BaseClient`.
- `ReportDialogOptions` now extends `Record<string, unknown>` instead of `Record<string, any>` - this should not affect most users.

Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/tracing/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,6 @@ function _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parent
name,
parentSampled,
attributes,
transactionContext: {
name,
parentSampled,
},
});

const rootSpan = new SentrySpan({
Expand Down
9 changes: 0 additions & 9 deletions packages/core/src/types-hoist/samplingcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ export interface CustomSamplingContext {
* Adds default data to data provided by the user. See {@link Hub.startTransaction}
*/
export interface SamplingContext extends CustomSamplingContext {
/**
* Context data with which transaction being sampled was created.
* @deprecated This is duplicate data and will be removed eventually.
*/
transactionContext: {
name: string;
parentSampled?: boolean | undefined;
};

/**
* Sampling decision from the parent transaction, if any.
*/
Expand Down
1 change: 0 additions & 1 deletion packages/core/test/lib/tracing/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ describe('startSpan', () => {
test2: 'aa',
test3: 'bb',
},
transactionContext: expect.objectContaining({ name: 'outer', parentSampled: undefined }),
});
});

Expand Down
4 changes: 0 additions & 4 deletions packages/opentelemetry/src/sampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export class SentrySampler implements Sampler {
const [sampled, sampleRate] = sampleSpan(options, {
name: inferredSpanName,
attributes: mergedAttributes,
transactionContext: {
name: inferredSpanName,
parentSampled,
},
parentSampled,
});

Expand Down
10 changes: 0 additions & 10 deletions packages/opentelemetry/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,6 @@ describe('trace (sampling)', () => {
parentSampled: undefined,
name: 'outer',
attributes: {},
transactionContext: { name: 'outer', parentSampled: undefined },
});

// Now return `false`, it should not sample
Expand All @@ -1342,15 +1341,13 @@ describe('trace (sampling)', () => {
parentSampled: undefined,
name: 'outer',
attributes: {},
transactionContext: { name: 'outer', parentSampled: undefined },
}),
);
expect(tracesSampler).toHaveBeenCalledWith(
expect.objectContaining({
parentSampled: undefined,
name: 'outer2',
attributes: {},
transactionContext: { name: 'outer2', parentSampled: undefined },
}),
);

Expand Down Expand Up @@ -1391,7 +1388,6 @@ describe('trace (sampling)', () => {
attr2: 1,
'sentry.op': 'test.op',
},
transactionContext: { name: 'outer', parentSampled: undefined },
});

// Now return `0`, it should not sample
Expand All @@ -1411,7 +1407,6 @@ describe('trace (sampling)', () => {
parentSampled: undefined,
name: 'outer2',
attributes: {},
transactionContext: { name: 'outer2', parentSampled: undefined },
}),
);

Expand All @@ -1434,7 +1429,6 @@ describe('trace (sampling)', () => {
parentSampled: undefined,
name: 'outer3',
attributes: {},
transactionContext: { name: 'outer3', parentSampled: undefined },
});
});

Expand Down Expand Up @@ -1468,10 +1462,6 @@ describe('trace (sampling)', () => {
parentSampled: true,
name: 'outer',
attributes: {},
transactionContext: {
name: 'outer',
parentSampled: true,
},
});
});

Expand Down
4 changes: 0 additions & 4 deletions packages/profiling-node/src/spanProfileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export function maybeProfileSpan(
profilesSampleRate = profilesSampler({
name: spanName,
attributes: data,
transactionContext: {
name: spanName,
parentSampled,
},
parentSampled,
...customSamplingContext,
});
Expand Down
36 changes: 17 additions & 19 deletions packages/solidstart/src/config/wrapServerEntryWithDynamicImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOp
return { id: source, moduleSideEffects: true };
}

if (additionalImports && additionalImports.includes(source)) {
if (additionalImports?.includes(source)) {
// When importing additional imports like "import-in-the-middle/hook.mjs" in the returned code of the `load()` function below:
// By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it
// By importing "import-in-the-middle/hook.mjs", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.
Expand All @@ -70,7 +70,7 @@ export function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOp
const resolution = await this.resolve(source, importer, options);

// If it cannot be resolved or is external, just return it so that Rollup can display an error
if (!resolution || (resolution && resolution.external)) return resolution;
if (!resolution || resolution?.external) return resolution;

const moduleInfo = await this.load(resolution);

Expand Down Expand Up @@ -146,23 +146,21 @@ export function extractFunctionReexportQueryParameters(query: string): { wrap: s
const wrapMatch = query.match(wrapRegex);
const reexportMatch = query.match(reexportRegex);

const wrap =
wrapMatch && wrapMatch[1]
? wrapMatch[1]
.split(',')
.filter(param => param !== '')
// Sanitize, as code could be injected with another rollup plugin
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
: [];

const reexport =
reexportMatch && reexportMatch[1]
? reexportMatch[1]
.split(',')
.filter(param => param !== '' && param !== 'default')
// Sanitize, as code could be injected with another rollup plugin
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
: [];
const wrap = wrapMatch?.[1]
? wrapMatch[1]
.split(',')
.filter(param => param !== '')
// Sanitize, as code could be injected with another rollup plugin
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
: [];

const reexport = reexportMatch?.[1]
? reexportMatch[1]
.split(',')
.filter(param => param !== '' && param !== 'default')
// Sanitize, as code could be injected with another rollup plugin
.map((str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
: [];

return { wrap, reexport };
}
Expand Down
Loading