import { Resource } from '@opentelemetry/resources' ; import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions' ; import { getInstrumentation } from './instrumentation-singelton' ; import { registerInstrumentationTestingProvider } from './otel-default-provider' ; import { resetMemoryExporter } from './otel-provider-api' ; export * from './instrumentation-singelton' ; export * from './otel-provider-api' ; export * from './otel-default-provider' ; export const mochaHooks = { beforeAll ( done ) { let serviceName = 'unknown_instrumentation' ; if ( process . env . OTEL_SERVICE_NAME ) { serviceName = process . env . OTEL_SERVICE_NAME ; } else { try { serviceName = require ( process . argv [ 1 ] + '/../../../package.json' ) . name ; } catch { } } const provider = registerInstrumentationTestingProvider ( { resource : new Resource ( { [ SemanticResourceAttributes . SERVICE_NAME ] : serviceName , } ) , } ) ; getInstrumentation ( ) ?. setTracerProvider ( provider ) ; done ( ) ; } , beforeEach ( done ) { resetMemoryExporter ( ) ; getInstrumentation ( ) ?. setConfig ( { } ) ; done ( ) ; } , } ;