diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 8aafec61fc..61e7c99665 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -1036,7 +1036,7 @@ private void InitializeClientTelemetry() this.clientTelemetry = ClientTelemetry.CreateAndStartBackgroundTelemetry( clientId: this.clientId, httpClient: this.httpClient, - userAgent: this.ConnectionPolicy.UserAgentContainer.UserAgent, + userAgent: this.ConnectionPolicy.UserAgentContainer.BaseUserAgent, connectionMode: this.ConnectionPolicy.ConnectionMode, authorizationTokenProvider: this.cosmosAuthorization, diagnosticsHelper: DiagnosticsHandlerHelper.Instance, diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs index 961c5d25d1..737be92e05 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/ClientTelemetryTests.cs @@ -974,6 +974,7 @@ private static void AssertAccountLevelInformation( Assert.IsNotNull(telemetryInfo.ProcessId); Assert.AreEqual(HashingExtension.ComputeHash(System.Diagnostics.Process.GetCurrentProcess().ProcessName), telemetryInfo.ProcessId); Assert.IsNotNull(telemetryInfo.UserAgent); + Assert.IsFalse(telemetryInfo.UserAgent.Contains("userAgentSuffix"), "Useragent should not have suffix appended"); // Useragent should not contain useragentsuffix as it can have PII Assert.IsNotNull(telemetryInfo.ConnectionMode); if(!string.IsNullOrEmpty(telemetryInfo.MachineId)) @@ -1090,7 +1091,8 @@ private async Task CreateClientAndContainer(ConnectionMode mode, } this.cosmosClientBuilder = this.cosmosClientBuilder - .WithHttpClientFactory(() => new HttpClient(handlerHelper)); + .WithHttpClientFactory(() => new HttpClient(handlerHelper)) + .WithApplicationName("userAgentSuffix"); this.cosmosClient = mode == ConnectionMode.Gateway ? this.cosmosClientBuilder.WithConnectionModeGateway().Build()