import { InstrumentationBase } from '@opentelemetry/instrumentation' ; const OTEL_TESTING_INSTRUMENTATION_SINGLETON = Symbol . for ( 'opentelemetry.testing.instrumentation_singleton' ) ; type OTelInstrumentationSingeltonGlobal = { [ OTEL_TESTING_INSTRUMENTATION_SINGLETON ] ? : InstrumentationBase ; } ; const _global = global as OTelInstrumentationSingeltonGlobal ; export const getInstrumentation = < T extends InstrumentationBase > ( ) : T | undefined => { return _global [ OTEL_TESTING_INSTRUMENTATION_SINGLETON ] as T ; } ; export const registerInstrumentationTesting = < T extends InstrumentationBase > ( instrumentation ) : T => { const existing = getInstrumentation < T > ( ) ; if ( existing ) { instrumentation . disable ( ) ; return existing ; } _global [ OTEL_TESTING_INSTRUMENTATION_SINGLETON ] = instrumentation ; return instrumentation ; } ;