@@ -7,7 +7,6 @@ import { SemanticAttributes, SemanticResourceAttributes } from '@opentelemetry/s
7
7
import { createTransport , Hub , makeMain } from '@sentry/core' ;
8
8
import { NodeClient } from '@sentry/node' ;
9
9
import { addExtensionMethods , Span as SentrySpan , SpanStatusType , Transaction } from '@sentry/tracing' ;
10
- import { Scope } from '@sentry/types' ;
11
10
import { resolvedSyncPromise } from '@sentry/utils' ;
12
11
13
12
import { SENTRY_SPAN_PROCESSOR_MAP , SentrySpanProcessor } from '../src/spanprocessor' ;
@@ -60,22 +59,6 @@ describe('SentrySpanProcessor', () => {
60
59
return transactionWithContext . _contexts ;
61
60
}
62
61
63
- // monkey-patch finish to store the context at finish time
64
- function monkeyPatchTransactionFinish ( transaction : Transaction ) {
65
- const monkeyPatchedTransaction = transaction as Transaction ;
66
-
67
- // eslint-disable-next-line @typescript-eslint/unbound-method
68
- const originalFinish = monkeyPatchedTransaction . finish ;
69
- // @ts -ignore accessing private property
70
- monkeyPatchedTransaction . _contexts = { } ;
71
- monkeyPatchedTransaction . finish = function ( endTimestamp ?: number | undefined ) {
72
- // @ts -ignore accessing private property
73
- monkeyPatchedTransaction . _contexts = ( transaction . _hub . getScope ( ) as unknown as Scope ) . _contexts ;
74
-
75
- return originalFinish . apply ( monkeyPatchedTransaction , [ endTimestamp ] ) ;
76
- } ;
77
- }
78
-
79
62
it ( 'creates a transaction' , async ( ) => {
80
63
const startTimestampMs = 1667381672875 ;
81
64
const endTimestampMs = 1667381672309 ;
@@ -173,7 +156,6 @@ describe('SentrySpanProcessor', () => {
173
156
const otelSpan = provider . getTracer ( 'default' ) . startSpan ( 'GET /users' ) ;
174
157
175
158
const transaction = getSpanForOtelSpan ( otelSpan ) as Transaction ;
176
- monkeyPatchTransactionFinish ( transaction ) ;
177
159
178
160
// context is only set after end
179
161
expect ( getContext ( transaction ) ) . toEqual ( { } ) ;
@@ -196,7 +178,6 @@ describe('SentrySpanProcessor', () => {
196
178
const otelSpan2 = provider . getTracer ( 'default' ) . startSpan ( 'GET /companies' ) ;
197
179
198
180
const transaction2 = getSpanForOtelSpan ( otelSpan2 ) as Transaction ;
199
- monkeyPatchTransactionFinish ( transaction2 ) ;
200
181
201
182
expect ( getContext ( transaction2 ) ) . toEqual ( { } ) ;
202
183
0 commit comments