@@ -7,7 +7,6 @@ import { SemanticAttributes, SemanticResourceAttributes } from '@opentelemetry/s
77import { createTransport , Hub , makeMain } from '@sentry/core' ;
88import { NodeClient } from '@sentry/node' ;
99import { addExtensionMethods , Span as SentrySpan , SpanStatusType , Transaction } from '@sentry/tracing' ;
10- import { Scope } from '@sentry/types' ;
1110import { resolvedSyncPromise } from '@sentry/utils' ;
1211
1312import { SENTRY_SPAN_PROCESSOR_MAP , SentrySpanProcessor } from '../src/spanprocessor' ;
@@ -60,22 +59,6 @@ describe('SentrySpanProcessor', () => {
6059 return transactionWithContext . _contexts ;
6160 }
6261
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-
7962 it ( 'creates a transaction' , async ( ) => {
8063 const startTimestampMs = 1667381672875 ;
8164 const endTimestampMs = 1667381672309 ;
@@ -173,7 +156,6 @@ describe('SentrySpanProcessor', () => {
173156 const otelSpan = provider . getTracer ( 'default' ) . startSpan ( 'GET /users' ) ;
174157
175158 const transaction = getSpanForOtelSpan ( otelSpan ) as Transaction ;
176- monkeyPatchTransactionFinish ( transaction ) ;
177159
178160 // context is only set after end
179161 expect ( getContext ( transaction ) ) . toEqual ( { } ) ;
@@ -196,7 +178,6 @@ describe('SentrySpanProcessor', () => {
196178 const otelSpan2 = provider . getTracer ( 'default' ) . startSpan ( 'GET /companies' ) ;
197179
198180 const transaction2 = getSpanForOtelSpan ( otelSpan2 ) as Transaction ;
199- monkeyPatchTransactionFinish ( transaction2 ) ;
200181
201182 expect ( getContext ( transaction2 ) ) . toEqual ( { } ) ;
202183
0 commit comments