Skip to content

Commit 68aee33

Browse files
avoid create new featureFlagTracing object when request tracing is disabled
1 parent 4ff6c57 commit 68aee33

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
3939
#client: AppConfigurationClient;
4040
#options: AzureAppConfigurationOptions | undefined;
4141
#isInitialLoadCompleted: boolean = false;
42-
#featureFlagTracing: FeatureFlagTracingOptions = new FeatureFlagTracingOptions();
42+
#featureFlagTracing: FeatureFlagTracingOptions | undefined;
4343

4444
// Refresh
4545
#refreshInterval: number = DEFAULT_REFRESH_INTERVAL_IN_MS;
@@ -66,6 +66,9 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
6666

6767
// Enable request tracing if not opt-out
6868
this.#requestTracingEnabled = requestTracingEnabled();
69+
if (this.#requestTracingEnabled) {
70+
this.#featureFlagTracing = new FeatureFlagTracingOptions();
71+
}
6972

7073
if (options?.trimKeyPrefixes) {
7174
this.#sortedTrimKeyPrefixes = [...options.trimKeyPrefixes].sort((a, b) => b.localeCompare(a));
@@ -282,7 +285,9 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
282285
selector.pageEtags = pageEtags;
283286
}
284287

285-
this.#featureFlagTracing.resetFeatureFlagTracing();
288+
if (this.#requestTracingEnabled && this.#featureFlagTracing !== undefined) {
289+
this.#featureFlagTracing.resetFeatureFlagTracing();
290+
}
286291

287292
// parse feature flags
288293
const featureFlags = await Promise.all(
@@ -545,13 +550,13 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
545550
throw new Error("The value of configuration setting cannot be undefined.");
546551
}
547552
const featureFlag = JSON.parse(rawFlag);
548-
549-
if (featureFlag[CONDITIONS_KEY_NAME] && featureFlag[CONDITIONS_KEY_NAME][CLIENT_FILTERS_KEY_NAME]) {
550-
for (const filter of featureFlag[CONDITIONS_KEY_NAME][CLIENT_FILTERS_KEY_NAME]) {
551-
this.#featureFlagTracing.updateFeatureFilterTracing(filter[NAME_KEY_NAME]);
553+
if (this.#requestTracingEnabled && this.#featureFlagTracing !== undefined) {
554+
if (featureFlag[CONDITIONS_KEY_NAME] && featureFlag[CONDITIONS_KEY_NAME][CLIENT_FILTERS_KEY_NAME]) {
555+
for (const filter of featureFlag[CONDITIONS_KEY_NAME][CLIENT_FILTERS_KEY_NAME]) {
556+
this.#featureFlagTracing.updateFeatureFilterTracing(filter[NAME_KEY_NAME]);
557+
}
552558
}
553559
}
554-
555560
return featureFlag;
556561
}
557562
}

0 commit comments

Comments
 (0)