@@ -25,6 +25,7 @@ import {
2525 CLIENT_FILTERS_KEY_NAME
2626} from "./featureManagement/constants.js" ;
2727import { FM_PACKAGE_NAME , AI_MIME_PROFILE , AI_CHAT_COMPLETION_MIME_PROFILE } from "./requestTracing/constants.js" ;
28+ import { parseContentType , isJsonContentType } from "./common/contentType.js" ;
2829import { AzureKeyVaultKeyValueAdapter } from "./keyvault/AzureKeyVaultKeyValueAdapter.js" ;
2930import { RefreshTimer } from "./refresh/RefreshTimer.js" ;
3031import { RequestTracingOptions , getConfigurationSettingWithTrace , listConfigurationSettingsWithTrace , requestTracingEnabled } from "./requestTracing/utils.js" ;
@@ -99,6 +100,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
99100 // enable request tracing if not opt-out
100101 this . #requestTracingEnabled = requestTracingEnabled ( ) ;
101102 if ( this . #requestTracingEnabled) {
103+ this . #aiConfigurationTracing = new AIConfigurationTracingOptions ( ) ;
102104 this . #featureFlagTracing = new FeatureFlagTracingOptions ( ) ;
103105 }
104106
@@ -419,9 +421,14 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
419421 await this . #updateWatchedKeyValuesEtag( loadedSettings ) ;
420422 }
421423
424+ if ( this . #requestTracingEnabled && this . #aiConfigurationTracing !== undefined ) {
425+ // Reset old AI configuration tracing in order to track the information present in the current response from server.
426+ this . #aiConfigurationTracing. reset ( ) ;
427+ }
428+
422429 // process key-values, watched settings have higher priority
423430 for ( const setting of loadedSettings ) {
424- const [ key , value ] = await this . #processKeyValues ( setting ) ;
431+ const [ key , value ] = await this . #processKeyValue ( setting ) ;
425432 keyValues . push ( [ key , value ] ) ;
426433 }
427434
@@ -470,6 +477,11 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
470477 const loadFeatureFlag = true ;
471478 const featureFlagSettings = await this . #loadConfigurationSettings( loadFeatureFlag ) ;
472479
480+ if ( this . #requestTracingEnabled && this . #featureFlagTracing !== undefined ) {
481+ // Reset old feature flag tracing in order to track the information present in the current response from server.
482+ this . #featureFlagTracing. reset ( ) ;
483+ }
484+
473485 // parse feature flags
474486 const featureFlags = await Promise . all (
475487 featureFlagSettings . map ( setting => this . #parseFeatureFlag( setting ) )
@@ -636,7 +648,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
636648 throw new Error ( "All clients failed to get configuration settings." ) ;
637649 }
638650
639- async #processKeyValues ( setting : ConfigurationSetting < string > ) : Promise < [ string , unknown ] > {
651+ async #processKeyValue ( setting : ConfigurationSetting < string > ) : Promise < [ string , unknown ] > {
640652 this . #setAIConfigurationTracing( setting ) ;
641653
642654 const [ key , value ] = await this . #processAdapters( setting ) ;
@@ -646,10 +658,19 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
646658
647659 #setAIConfigurationTracing( setting : ConfigurationSetting < string > ) : void {
648660 if ( this . #requestTracingEnabled && this . #aiConfigurationTracing !== undefined ) {
649- // Reset old AI configuration tracing in order to track the information present in the current response from server.
650- this . #aiConfigurationTracing. reset ( ) ;
651-
652-
661+ const contentType = parseContentType ( setting . contentType ) ;
662+ if ( isJsonContentType ( contentType ) ) {
663+ const profile = contentType ?. parameters [ "profile" ] ;
664+ if ( profile === undefined ) {
665+ return ;
666+ }
667+ if ( profile . includes ( AI_MIME_PROFILE ) ) {
668+ this . #aiConfigurationTracing. usesAIConfiguration = true ;
669+ }
670+ if ( profile . includes ( AI_CHAT_COMPLETION_MIME_PROFILE ) ) {
671+ this . #aiConfigurationTracing. usesAIChatCompletionConfiguration = true ;
672+ }
673+ }
653674 }
654675 }
655676
@@ -704,9 +725,6 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
704725
705726 #setFeatureFlagTracing( featureFlag : any ) : void {
706727 if ( this . #requestTracingEnabled && this . #featureFlagTracing !== undefined ) {
707- // Reset old feature flag tracing in order to track the information present in the current response from server.
708- this . #featureFlagTracing. reset ( ) ;
709-
710728 if ( featureFlag [ CONDITIONS_KEY_NAME ] &&
711729 featureFlag [ CONDITIONS_KEY_NAME ] [ CLIENT_FILTERS_KEY_NAME ] &&
712730 Array . isArray ( featureFlag [ CONDITIONS_KEY_NAME ] [ CLIENT_FILTERS_KEY_NAME ] ) ) {
0 commit comments