@@ -23,6 +23,16 @@ import {
2323import { EsbuildInstrumentationConfigMap } from '../types' ;
2424import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node' ;
2525
26+ const instrumentations = getNodeAutoInstrumentations ( ) ;
27+ const instrumentationModuleDefinitionsByInstrumentationName =
28+ Object . fromEntries (
29+ instrumentations . map ( i => [ i . instrumentationName , getModuleDefinitions ( i ) ] )
30+ ) ;
31+
32+ export const instrumentationModuleDefinitions = Object . values (
33+ instrumentationModuleDefinitionsByInstrumentationName
34+ ) . flat ( ) ;
35+
2636function getModuleDefinitions (
2737 instrumentation : Instrumentation
2838) : InstrumentationModuleDefinition [ ] {
@@ -33,9 +43,6 @@ function getModuleDefinitions(
3343 return [ ] ;
3444}
3545
36- export const instrumentations =
37- getNodeAutoInstrumentations ( ) . flatMap ( getModuleDefinitions ) ;
38-
3946function configGenerator < T extends { enabled ?: boolean } > (
4047 config ?: T
4148) : string | undefined {
@@ -58,9 +65,11 @@ export function getOtelPackageToInstrumentationConfig() {
5865 ) => string | undefined ;
5966 }
6067 > = { } ;
61- for ( const instrumentation of getNodeAutoInstrumentations ( ) ) {
68+ for ( const instrumentation of instrumentations ) {
6269 const instrumentationModuleDefinitions =
63- getModuleDefinitions ( instrumentation ) ;
70+ instrumentationModuleDefinitionsByInstrumentationName [
71+ instrumentation . instrumentationName
72+ ] ;
6473
6574 for ( const instrumentationModuleDefinition of instrumentationModuleDefinitions ) {
6675 otelPackageToInstrumentationConfig [ instrumentationModuleDefinition . name ] =
0 commit comments