Skip to content

Commit e4421ec

Browse files
add requestTracingOptions (#114)
1 parent 263859d commit e4421ec

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
6363
this.#options = options;
6464

6565
// Enable request tracing if not opt-out
66-
this.#requestTracingEnabled = requestTracingEnabled();
66+
this.#requestTracingEnabled = options?.requestTracingOptions?.enabled ?? requestTracingEnabled();
6767

6868
if (options?.trimKeyPrefixes) {
6969
this.#sortedTrimKeyPrefixes = [...options.trimKeyPrefixes].sort((a, b) => b.localeCompare(a));

src/AzureAppConfigurationOptions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { KeyVaultOptions } from "./keyvault/KeyVaultOptions.js";
66
import { RefreshOptions } from "./RefreshOptions.js";
77
import { SettingSelector } from "./types.js";
88
import { FeatureFlagOptions } from "./featureManagement/FeatureFlagOptions.js";
9+
import { RequestTracingOptions } from "./requestTracing/RequestTracingOptions.js";
910

1011
export const MaxRetries = 2;
1112
export const MaxRetryDelayInMs = 60000;
@@ -47,4 +48,9 @@ export interface AzureAppConfigurationOptions {
4748
* Specifies options used to configure feature flags.
4849
*/
4950
featureFlagOptions?: FeatureFlagOptions;
51+
52+
/**
53+
* Specifies options used to configure request tracing.
54+
*/
55+
requestTracingOptions?: RequestTracingOptions;
5056
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
/**
5+
* Options used to configure request tracing.
6+
*/
7+
export interface RequestTracingOptions {
8+
/**
9+
* Specifies whether request tracing is enabled.
10+
*/
11+
enabled: boolean;
12+
}

test/requestTracing.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ describe("request tracing", function () {
122122
delete process.env.AZURE_APP_CONFIGURATION_TRACING_DISABLED;
123123
});
124124

125+
it("should disable request tracing by RequestTracingOptions", async () => {
126+
try {
127+
await load(createMockedConnectionString(fakeEndpoint), {
128+
clientOptions,
129+
requestTracingOptions: {
130+
enabled: false
131+
}
132+
});
133+
} catch (e) { /* empty */ }
134+
expect(headerPolicy.headers).not.undefined;
135+
const correlationContext = headerPolicy.headers.get("Correlation-Context");
136+
expect(correlationContext).undefined;
137+
});
138+
125139
it("should have request type in correlation-context header when refresh is enabled", async () => {
126140
mockAppConfigurationClientListConfigurationSettings([{
127141
key: "app.settings.fontColor",

0 commit comments

Comments
 (0)