File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,14 @@ function contentLengthFromResponseHeaders(headers: Buffer[]) {
7676 return undefined ;
7777}
7878
79+ async function loadFetch ( ) {
80+ try {
81+ await fetch ( '' ) ;
82+ } catch ( _ ) {
83+ //
84+ }
85+ }
86+
7987// A combination of https://github.com/elastic/apm-agent-nodejs and
8088// https://github.com/gadget-inc/opentelemetry-instrumentations/blob/main/packages/opentelemetry-instrumentation-undici/src/index.ts
8189export class FetchInstrumentation implements Instrumentation {
@@ -110,7 +118,7 @@ export class FetchInstrumentation implements Instrumentation {
110118
111119 constructor ( config : FetchInstrumentationConfig ) {
112120 // Force load fetch API (since it's lazy loaded in Node 18)
113- fetch ( '' ) . catch ( ( ) => { } ) ;
121+ loadFetch ( ) ;
114122 this . channelSubs = [ ] ;
115123 this . meter = metrics . getMeter ( this . instrumentationName , this . instrumentationVersion ) ;
116124 this . tracer = trace . getTracer ( this . instrumentationName , this . instrumentationVersion ) ;
You can’t perform that action at this time.
0 commit comments