@@ -26,6 +26,9 @@ declare const global: {[index: string]: any};
2626// libraries related info.
2727global . instrumentationAdded = false ;
2828
29+ // The global variable to avoid records inspection once instrumentation already written to prevent perf impact
30+ global . shouldSkipInstrumentationCheck = false ;
31+
2932// The variable to hold cached library version
3033let libraryVersion : string ;
3134
@@ -46,6 +49,11 @@ export type InstrumentationInfo = {name: string; version: string};
4649export function populateInstrumentationInfo (
4750 entry : Entry | Entry [ ]
4851) : [ Entry [ ] , boolean ] {
52+ // Check if instrumentation data was already written once. This prevents also inspection of
53+ // the entries for instrumentation data to prevent perf degradation
54+ if ( global . shouldSkipInstrumentationCheck ) {
55+ return [ arrify ( entry ) , false ] ;
56+ }
4957 // Update the flag indicating that instrumentation entry was already added once,
5058 // so any subsequent calls to this method will not add a separate instrumentation log entry
5159 let isWritten = setInstrumentationStatus ( true ) ;
@@ -64,7 +72,10 @@ export function populateInstrumentationInfo(
6472 validateAndUpdateInstrumentation ( info ) ;
6573 // Indicate that instrumentation info log entry already exists
6674 // and that current library info was added to existing log entry
67- isInfoAdded = isWritten = true ;
75+ global . shouldSkipInstrumentationCheck =
76+ isInfoAdded =
77+ isWritten =
78+ true ;
6879 }
6980 entries . push ( entryItem ) ;
7081 }
@@ -74,7 +85,7 @@ export function populateInstrumentationInfo(
7485 // instrumentation data for this library
7586 if ( ! isWritten ) {
7687 entries . push ( createDiagnosticEntry ( undefined , undefined ) ) ;
77- isInfoAdded = true ;
88+ global . shouldSkipInstrumentationCheck = isInfoAdded = true ;
7889 }
7990 return [ entries , isInfoAdded ] ;
8091}
0 commit comments