@@ -11,8 +11,7 @@ import { DEFAULT_REFRESH_INTERVAL_IN_MS, MIN_REFRESH_INTERVAL_IN_MS } from "./Re
1111import { Disposable } from "./common/disposable" ;
1212import { AzureKeyVaultKeyValueAdapter } from "./keyvault/AzureKeyVaultKeyValueAdapter" ;
1313import { RefreshTimer } from "./refresh/RefreshTimer" ;
14- import { CORRELATION_CONTEXT_HEADER_NAME } from "./requestTracing/constants" ;
15- import { createCorrelationContextHeader , requestTracingEnabled } from "./requestTracing/utils" ;
14+ import { getConfigurationSettingWithTrace , listConfigurationSettingsWithTrace , requestTracingEnabled } from "./requestTracing/utils" ;
1615import { KeyFilter , LabelFilter , SettingSelector } from "./types" ;
1716
1817export class AzureAppConfigurationImpl implements AzureAppConfiguration {
@@ -140,15 +139,16 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
140139 labelFilter : selector . labelFilter
141140 } ;
142141
143- if ( this . #requestTracingEnabled) {
144- listOptions . requestOptions = {
145- customHeaders : {
146- [ CORRELATION_CONTEXT_HEADER_NAME ] : createCorrelationContextHeader ( this . #options, this . #isInitialLoadCompleted)
147- }
148- }
149- }
150-
151- const settings = this . #client. listConfigurationSettings ( listOptions ) ;
142+ const requestTraceOptions = {
143+ requestTracingEnabled : this . #requestTracingEnabled,
144+ initialLoadCompleted : this . #isInitialLoadCompleted,
145+ appConfigOptions : this . #options
146+ } ;
147+ const settings = listConfigurationSettingsWithTrace (
148+ requestTraceOptions ,
149+ this . #client,
150+ listOptions
151+ ) ;
152152
153153 for await ( const setting of settings ) {
154154 if ( ! isFeatureFlag ( setting ) ) { // exclude feature flags
@@ -174,7 +174,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
174174 } else {
175175 // Send a request to retrieve key-value since it may be either not loaded or loaded with a different label or different casing
176176 const { key, label } = sentinel ;
177- const response = await this . #getConfigurationSettingWithTrace ( { key, label } ) ;
177+ const response = await this . #getConfigurationSetting ( { key, label } ) ;
178178 if ( response ) {
179179 sentinel . etag = response . etag ;
180180 } else {
@@ -270,7 +270,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
270270 // try refresh if any of watched settings is changed.
271271 let needRefresh = false ;
272272 for ( const sentinel of this . #sentinels. values ( ) ) {
273- const response = await this . #getConfigurationSettingWithTrace ( sentinel , {
273+ const response = await this . #getConfigurationSetting ( sentinel , {
274274 onlyIfChanged : true
275275 } ) ;
276276
@@ -342,18 +342,24 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
342342 return key ;
343343 }
344344
345- async #getConfigurationSettingWithTrace( configurationSettingId : ConfigurationSettingId , customOptions ?: GetConfigurationSettingOptions ) : Promise < GetConfigurationSettingResponse | undefined > {
345+ /**
346+ * Get a configuration setting by key and label. If the setting is not found, return undefine instead of throwing an error.
347+ */
348+ async #getConfigurationSetting( configurationSettingId : ConfigurationSettingId , customOptions ?: GetConfigurationSettingOptions ) : Promise < GetConfigurationSettingResponse | undefined > {
346349 let response : GetConfigurationSettingResponse | undefined ;
347350 try {
348- const options = { ...customOptions ?? { } } ;
349- if ( this . #requestTracingEnabled) {
350- options . requestOptions = {
351- customHeaders : {
352- [ CORRELATION_CONTEXT_HEADER_NAME ] : createCorrelationContextHeader ( this . #options, this . #isInitialLoadCompleted)
353- }
354- }
355- }
356- response = await this . #client. getConfigurationSetting ( configurationSettingId , options ) ;
351+ const requestTraceOptions = {
352+ requestTracingEnabled : this . #requestTracingEnabled,
353+ initialLoadCompleted : this . #isInitialLoadCompleted,
354+ appConfigOptions : this . #options
355+ } ;
356+ response = await getConfigurationSettingWithTrace (
357+ requestTraceOptions ,
358+ this . #client,
359+ configurationSettingId ,
360+ customOptions
361+ ) ;
362+
357363 } catch ( error ) {
358364 if ( error instanceof RestError && error . statusCode === 404 ) {
359365 response = undefined ;
0 commit comments