1
- import { notifyEventProcessors } from '@sentry/core' ;
2
1
import { OpenTelemetryScope } from '@sentry/opentelemetry' ;
3
- import type {
4
- Attachment ,
5
- Breadcrumb ,
6
- Client ,
7
- Event ,
8
- EventHint ,
9
- EventProcessor ,
10
- Severity ,
11
- SeverityLevel ,
12
- } from '@sentry/types' ;
2
+ import type { Attachment , Breadcrumb , Client , Event , EventHint , Severity , SeverityLevel } from '@sentry/types' ;
13
3
import { uuid4 } from '@sentry/utils' ;
14
4
15
5
import { getGlobalCarrier } from './globals' ;
@@ -116,13 +106,7 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
116
106
117
107
/** @inheritdoc */
118
108
public getAttachments ( ) : Attachment [ ] {
119
- const data = getGlobalScope ( ) . getScopeData ( ) ;
120
- const isolationScopeData = this . _getIsolationScope ( ) . getScopeData ( ) ;
121
- const scopeData = this . getScopeData ( ) ;
122
-
123
- // Merge data together, in order
124
- mergeData ( data , isolationScopeData ) ;
125
- mergeData ( data , scopeData ) ;
109
+ const data = this . getScopeData ( ) ;
126
110
127
111
return data . attachments ;
128
112
}
@@ -200,7 +184,7 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
200
184
}
201
185
202
186
/** Get all relevant data for this scope. */
203
- public getScopeData ( ) : ScopeData {
187
+ public getPerScopeData ( ) : ScopeData {
204
188
const {
205
189
_breadcrumbs,
206
190
_attachments,
@@ -230,63 +214,17 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
230
214
} ;
231
215
}
232
216
233
- /**
234
- * Applies data from the scope to the event and runs all event processors on it.
235
- *
236
- * @param event Event
237
- * @param hint Object containing additional information about the original exception, for use by the event processors.
238
- * @hidden
239
- */
240
- public applyToEvent (
241
- event : Event ,
242
- hint : EventHint = { } ,
243
- additionalEventProcessors : EventProcessor [ ] = [ ] ,
244
- ) : PromiseLike < Event | null > {
245
- const data = getGlobalScope ( ) . getScopeData ( ) ;
246
- const isolationScopeData = this . _getIsolationScope ( ) . getScopeData ( ) ;
247
- const scopeData = this . getScopeData ( ) ;
217
+ /** @inheritdoc */
218
+ public getScopeData ( ) : ScopeData {
219
+ const data = getGlobalScope ( ) . getPerScopeData ( ) ;
220
+ const isolationScopeData = this . _getIsolationScope ( ) . getPerScopeData ( ) ;
221
+ const scopeData = this . getPerScopeData ( ) ;
248
222
249
223
// Merge data together, in order
250
224
mergeData ( data , isolationScopeData ) ;
251
225
mergeData ( data , scopeData ) ;
252
226
253
- // Apply the data
254
- const { extra, tags, user, contexts, level, sdkProcessingMetadata, breadcrumbs, fingerprint, eventProcessors } =
255
- data ;
256
-
257
- mergePropKeep ( event , 'extra' , extra ) ;
258
- mergePropKeep ( event , 'tags' , tags ) ;
259
- mergePropKeep ( event , 'user' , user ) ;
260
- mergePropKeep ( event , 'contexts' , contexts ) ;
261
- mergePropKeep ( event , 'sdkProcessingMetadata' , sdkProcessingMetadata ) ;
262
- event . sdkProcessingMetadata = {
263
- ...event . sdkProcessingMetadata ,
264
- propagationContext : this . _propagationContext ,
265
- } ;
266
-
267
- mergeArray ( event , 'breadcrumbs' , breadcrumbs ) ;
268
- mergeArray ( event , 'fingerprint' , fingerprint ) ;
269
-
270
- if ( level ) {
271
- event . level = level ;
272
- }
273
-
274
- const allEventProcessors = [ ...additionalEventProcessors , ...eventProcessors ] ;
275
-
276
- // Apply additional things to the event
277
- if ( this . _transactionName ) {
278
- event . transaction = this . _transactionName ;
279
- }
280
-
281
- return notifyEventProcessors ( allEventProcessors , event , hint ) ;
282
- }
283
-
284
- /**
285
- * Get all breadcrumbs attached to this scope.
286
- * @internal
287
- */
288
- public getBreadcrumbs ( ) : Breadcrumb [ ] {
289
- return this . _breadcrumbs ;
227
+ return data ;
290
228
}
291
229
292
230
/** Get the isolation scope for this scope. */
@@ -308,6 +246,7 @@ export function mergeData(data: ScopeData, mergeData: ScopeData): void {
308
246
fingerprint,
309
247
eventProcessors,
310
248
attachments,
249
+ propagationContext,
311
250
} = mergeData ;
312
251
313
252
mergePropOverwrite ( data , 'extra' , extra ) ;
@@ -335,6 +274,8 @@ export function mergeData(data: ScopeData, mergeData: ScopeData): void {
335
274
if ( attachments . length ) {
336
275
data . attachments = [ ...data . attachments , ...attachments ] ;
337
276
}
277
+
278
+ data . propagationContext = { ...data . propagationContext , ...propagationContext } ;
338
279
}
339
280
340
281
/**
0 commit comments