1
1
import type {
2
2
Contexts ,
3
- DynamicSamplingContext ,
4
3
Hub ,
5
4
MeasurementUnit ,
6
5
Measurements ,
@@ -9,15 +8,14 @@ import type {
9
8
Transaction as TransactionInterface ,
10
9
TransactionArguments ,
11
10
TransactionEvent ,
12
- TransactionMetadata ,
13
11
TransactionSource ,
14
12
} from '@sentry/types' ;
15
13
import { dropUndefinedKeys , logger } from '@sentry/utils' ;
16
14
17
15
import { DEBUG_BUILD } from '../debug-build' ;
18
16
import { getCurrentHub } from '../hub' ;
19
17
import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary' ;
20
- import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE , SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes' ;
18
+ import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes' ;
21
19
import { getSpanDescendants , spanTimeInputToSeconds , spanToJSON , spanToTraceContext } from '../utils/spanUtils' ;
22
20
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext' ;
23
21
import { SentrySpan } from './sentrySpan' ;
@@ -38,11 +36,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
38
36
39
37
private _trimEnd ?: boolean | undefined ;
40
38
41
- // DO NOT yet remove this property, it is used in a hack for v7 backwards compatibility.
42
- private _frozenDynamicSamplingContext : Readonly < Partial < DynamicSamplingContext > > | undefined ;
43
-
44
- private _metadata : Partial < TransactionMetadata > ;
45
-
46
39
/**
47
40
* This constructor should never be called manually.
48
41
* @internal
@@ -61,56 +54,14 @@ export class Transaction extends SentrySpan implements TransactionInterface {
61
54
62
55
this . _name = transactionContext . name || '' ;
63
56
64
- this . _metadata = {
65
- // eslint-disable-next-line deprecation/deprecation
66
- ...transactionContext . metadata ,
67
- } ;
68
-
69
57
this . _trimEnd = transactionContext . trimEnd ;
70
58
71
59
this . _attributes = {
72
60
[ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'custom' ,
73
61
...this . _attributes ,
74
62
} ;
75
-
76
- // If Dynamic Sampling Context is provided during the creation of the transaction, we freeze it as it usually means
77
- // there is incoming Dynamic Sampling Context. (Either through an incoming request, a baggage meta-tag, or other means)
78
- const incomingDynamicSamplingContext = this . _metadata . dynamicSamplingContext ;
79
- if ( incomingDynamicSamplingContext ) {
80
- // We shallow copy this in case anything writes to the original reference of the passed in `dynamicSamplingContext`
81
- this . _frozenDynamicSamplingContext = { ...incomingDynamicSamplingContext } ;
82
- }
83
63
}
84
64
85
- // This sadly conflicts with the getter/setter ordering :(
86
-
87
- /**
88
- * Get the metadata for this transaction.
89
- * @deprecated Use `spanGetMetadata(transaction)` instead.
90
- */
91
- public get metadata ( ) : TransactionMetadata {
92
- // We merge attributes in for backwards compatibility
93
- return {
94
- // Legacy metadata
95
- ...this . _metadata ,
96
-
97
- // From attributes
98
- ...( this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ] && {
99
- sampleRate : this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE ] as TransactionMetadata [ 'sampleRate' ] ,
100
- } ) ,
101
- } ;
102
- }
103
-
104
- /**
105
- * Update the metadata for this transaction.
106
- * @deprecated Use `spanGetMetadata(transaction)` instead.
107
- */
108
- public set metadata ( metadata : TransactionMetadata ) {
109
- this . _metadata = metadata ;
110
- }
111
-
112
- /* eslint-enable @typescript-eslint/member-ordering */
113
-
114
65
/** @inheritdoc */
115
66
public updateName ( name : string ) : this {
116
67
this . _name = name ;
@@ -127,14 +78,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
127
78
this . _measurements [ name ] = { value, unit } ;
128
79
}
129
80
130
- /**
131
- * Store metadata on this transaction.
132
- * @deprecated Use attributes or store data on the scope instead.
133
- */
134
- public setMetadata ( newMetadata : Partial < TransactionMetadata > ) : void {
135
- this . _metadata = { ...this . _metadata , ...newMetadata } ;
136
- }
137
-
138
81
/**
139
82
* @inheritDoc
140
83
*/
@@ -148,6 +91,30 @@ export class Transaction extends SentrySpan implements TransactionInterface {
148
91
return this . _hub . captureEvent ( transaction ) ;
149
92
}
150
93
94
+ /**
95
+ * @inheritDoc
96
+ */
97
+ public toContext ( ) : TransactionArguments {
98
+ // eslint-disable-next-line deprecation/deprecation
99
+ const spanContext = super . toContext ( ) ;
100
+
101
+ return dropUndefinedKeys ( {
102
+ ...spanContext ,
103
+ name : this . _name ,
104
+ trimEnd : this . _trimEnd ,
105
+ } ) ;
106
+ }
107
+
108
+ /**
109
+ * Override the current hub with a new one.
110
+ * Used if you want another hub to finish the transaction.
111
+ *
112
+ * @internal
113
+ */
114
+ public setHub ( hub : Hub ) : void {
115
+ this . _hub = hub ;
116
+ }
117
+
151
118
/**
152
119
* Finish the transaction & prepare the event to send to Sentry.
153
120
*/
@@ -198,9 +165,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
198
165
199
166
const { scope : capturedSpanScope , isolationScope : capturedSpanIsolationScope } = getCapturedScopesOnSpan ( this ) ;
200
167
201
- // eslint-disable-next-line deprecation/deprecation
202
- const { metadata } = this ;
203
-
204
168
const source = this . _attributes [ 'sentry.source' ] as TransactionSource | undefined ;
205
169
206
170
const transaction : TransactionEvent = {
@@ -215,7 +179,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
215
179
transaction : this . _name ,
216
180
type : 'transaction' ,
217
181
sdkProcessingMetadata : {
218
- ...metadata ,
219
182
capturedSpanScope,
220
183
capturedSpanIsolationScope,
221
184
...dropUndefinedKeys ( {
0 commit comments