Skip to content

Commit a5de993

Browse files
authored
feat(core)!: Remove transactionContext from samplingContext (#14904)
Removes `transactionContext` as it only includes duplicated data.
1 parent 7fb7632 commit a5de993

File tree

7 files changed

+1
-32
lines changed

7 files changed

+1
-32
lines changed

Diff for: docs/migration/v8-to-v9.md

+1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Since v9, the types have been merged into `@sentry/core`, which removed some of
263263
- The `Request` type has been removed. Use `RequestEventData` type instead.
264264
- The `IntegrationClass` type is no longer exported - it was not used anymore. Instead, use `Integration` or `IntegrationFn`.
265265
- The `samplingContext.request` attribute in the `tracesSampler` has been removed. Use `samplingContext.normalizedRequest` instead. Note that the type of `normalizedRequest` differs from `request`.
266+
- The `samplingContext.transactionContext` object in the `tracesSampler` has been removed. All object attributes are available in the top-level of `samplingContext`.
266267
- `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`.
267268
- `ReportDialogOptions` now extends `Record<string, unknown>` instead of `Record<string, any>` - this should not affect most users.
268269
- The `RequestDataIntegrationOptions` type has been removed. There is no replacement.

Diff for: packages/core/src/tracing/trace.ts

-4
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@ function _startRootSpan(spanArguments: SentrySpanArguments, scope: Scope, parent
408408
name,
409409
parentSampled,
410410
attributes,
411-
transactionContext: {
412-
name,
413-
parentSampled,
414-
},
415411
});
416412

417413
const rootSpan = new SentrySpan({

Diff for: packages/core/src/types-hoist/samplingcontext.ts

-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ export interface CustomSamplingContext {
1515
* Adds default data to data provided by the user. See {@link Hub.startTransaction}
1616
*/
1717
export interface SamplingContext extends CustomSamplingContext {
18-
/**
19-
* Context data with which transaction being sampled was created.
20-
* @deprecated This is duplicate data and will be removed eventually.
21-
*/
22-
transactionContext: {
23-
name: string;
24-
parentSampled?: boolean | undefined;
25-
};
26-
2718
/**
2819
* Sampling decision from the parent transaction, if any.
2920
*/

Diff for: packages/core/test/lib/tracing/trace.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ describe('startSpan', () => {
606606
test2: 'aa',
607607
test3: 'bb',
608608
},
609-
transactionContext: expect.objectContaining({ name: 'outer', parentSampled: undefined }),
610609
});
611610
});
612611

Diff for: packages/opentelemetry/src/sampler.ts

-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ export class SentrySampler implements Sampler {
103103
const [sampled, sampleRate] = sampleSpan(options, {
104104
name: inferredSpanName,
105105
attributes: mergedAttributes,
106-
transactionContext: {
107-
name: inferredSpanName,
108-
parentSampled,
109-
},
110106
parentSampled,
111107
});
112108

Diff for: packages/opentelemetry/test/trace.test.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ describe('trace (sampling)', () => {
13441344
parentSampled: undefined,
13451345
name: 'outer',
13461346
attributes: {},
1347-
transactionContext: { name: 'outer', parentSampled: undefined },
13481347
});
13491348

13501349
// Now return `false`, it should not sample
@@ -1364,15 +1363,13 @@ describe('trace (sampling)', () => {
13641363
parentSampled: undefined,
13651364
name: 'outer',
13661365
attributes: {},
1367-
transactionContext: { name: 'outer', parentSampled: undefined },
13681366
}),
13691367
);
13701368
expect(tracesSampler).toHaveBeenCalledWith(
13711369
expect.objectContaining({
13721370
parentSampled: undefined,
13731371
name: 'outer2',
13741372
attributes: {},
1375-
transactionContext: { name: 'outer2', parentSampled: undefined },
13761373
}),
13771374
);
13781375

@@ -1413,7 +1410,6 @@ describe('trace (sampling)', () => {
14131410
attr2: 1,
14141411
'sentry.op': 'test.op',
14151412
},
1416-
transactionContext: { name: 'outer', parentSampled: undefined },
14171413
});
14181414

14191415
// Now return `0`, it should not sample
@@ -1433,7 +1429,6 @@ describe('trace (sampling)', () => {
14331429
parentSampled: undefined,
14341430
name: 'outer2',
14351431
attributes: {},
1436-
transactionContext: { name: 'outer2', parentSampled: undefined },
14371432
}),
14381433
);
14391434

@@ -1456,7 +1451,6 @@ describe('trace (sampling)', () => {
14561451
parentSampled: undefined,
14571452
name: 'outer3',
14581453
attributes: {},
1459-
transactionContext: { name: 'outer3', parentSampled: undefined },
14601454
});
14611455
});
14621456

@@ -1490,10 +1484,6 @@ describe('trace (sampling)', () => {
14901484
parentSampled: true,
14911485
name: 'outer',
14921486
attributes: {},
1493-
transactionContext: {
1494-
name: 'outer',
1495-
parentSampled: true,
1496-
},
14971487
});
14981488
});
14991489

Diff for: packages/profiling-node/src/spanProfileUtils.ts

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ export function maybeProfileSpan(
4848
profilesSampleRate = profilesSampler({
4949
name: spanName,
5050
attributes: data,
51-
transactionContext: {
52-
name: spanName,
53-
parentSampled,
54-
},
5551
parentSampled,
5652
...customSamplingContext,
5753
});

0 commit comments

Comments
 (0)