@@ -130,28 +130,13 @@ export function createCorrelationContextHeader(requestTracingOptions: RequestTra
130130 keyValues . set ( FM_VERSION_KEY , requestTracingOptions . fmVersion ) ;
131131 }
132132
133- // Compact tags: Features=LB+AI+AICC...
134- if ( appConfigOptions ?. loadBalancingEnabled || requestTracingOptions . aiConfigurationTracing ?. usesAnyTracingFeature ( ) ) {
135- const tags : string [ ] = [ ] ;
136- if ( appConfigOptions ?. loadBalancingEnabled ) {
137- tags . push ( LOAD_BALANCE_CONFIGURED_TAG ) ;
138- }
139- if ( requestTracingOptions . aiConfigurationTracing ?. usesAIConfiguration ) {
140- tags . push ( AI_CONFIGURATION_TAG ) ;
141- }
142- if ( requestTracingOptions . aiConfigurationTracing ?. usesAIChatCompletionConfiguration ) {
143- tags . push ( AI_CHAT_COMPLETION_CONFIGURATION_TAG ) ;
144- }
145-
146- if ( tags . length > 0 ) {
147- keyValues . set ( FEATURES_KEY , tags . join ( DELIMITER ) ) ;
148- }
149- }
133+ // Use compact tags for new tracing features: Features=LB+AI+AICC...
134+ keyValues . set ( FEATURES_KEY , usesAnyTracingFeature ( requestTracingOptions ) ? createFeaturesString ( requestTracingOptions ) : undefined ) ;
150135
151136 const contextParts : string [ ] = [ ] ;
152- for ( const [ k , v ] of keyValues ) {
153- if ( v !== undefined ) {
154- contextParts . push ( `${ k } =${ v } ` ) ;
137+ for ( const [ key , value ] of keyValues ) {
138+ if ( value !== undefined ) {
139+ contextParts . push ( `${ key } =${ value } ` ) ;
155140 }
156141 }
157142 for ( const tag of tags ) {
@@ -167,6 +152,25 @@ export function requestTracingEnabled(): boolean {
167152 return ! disabled ;
168153}
169154
155+ function usesAnyTracingFeature ( requestTracingOptions : RequestTracingOptions ) : boolean {
156+ return ( requestTracingOptions . appConfigOptions ?. loadBalancingEnabled ?? false ) ||
157+ ( requestTracingOptions . aiConfigurationTracing ?. usesAnyTracingFeature ( ) ?? false ) ;
158+ }
159+
160+ function createFeaturesString ( requestTracingOptions : RequestTracingOptions ) : string {
161+ const tags : string [ ] = [ ] ;
162+ if ( requestTracingOptions . appConfigOptions ?. loadBalancingEnabled ) {
163+ tags . push ( LOAD_BALANCE_CONFIGURED_TAG ) ;
164+ }
165+ if ( requestTracingOptions . aiConfigurationTracing ?. usesAIConfiguration ) {
166+ tags . push ( AI_CONFIGURATION_TAG ) ;
167+ }
168+ if ( requestTracingOptions . aiConfigurationTracing ?. usesAIChatCompletionConfiguration ) {
169+ tags . push ( AI_CHAT_COMPLETION_CONFIGURATION_TAG ) ;
170+ }
171+ return tags . join ( DELIMITER ) ;
172+ }
173+
170174function getEnvironmentVariable ( name : string ) {
171175 // Make it compatible with non-Node.js runtime
172176 if ( typeof process !== "undefined" && typeof process ?. env === "object" ) {
0 commit comments