diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs index f0ac635d81..6700697914 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbEventSource.cs @@ -31,19 +31,12 @@ public static void RecordDiagnosticsForRequests( Documents.OperationType operationType, OpenTelemetryAttributes response) { - if (config.EnableDiagnosticsTraceForAllRequests) + if (DiagnosticsFilterHelper.IsTracingNeeded( + config: config, + operationType: operationType, + response: response) && CosmosDbEventSource.IsEnabled(EventLevel.Warning)) { - CosmosDbEventSource.Singleton.WriteInfoEvent(response.Diagnostics.ToString()); - } - else - { - if (DiagnosticsFilterHelper.IsTracingNeeded( - config: config, - operationType: operationType, - response: response) && CosmosDbEventSource.IsEnabled(EventLevel.Warning)) - { - CosmosDbEventSource.Singleton.WriteWarningEvent(response.Diagnostics.ToString()); - } + CosmosDbEventSource.Singleton.WriteWarningEvent(response.Diagnostics.ToString()); } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DistributedTracingOptions.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DistributedTracingOptions.cs index 078a554980..652b6b9e3f 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DistributedTracingOptions.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DistributedTracingOptions.cs @@ -21,43 +21,11 @@ internal sealed class DistributedTracingOptions /// Default Latency threshold for QUERY operation /// internal static readonly TimeSpan DefaultQueryTimeoutThreshold = TimeSpan.FromMilliseconds(500); - private bool enableDiagnosticsTraceForAllRequests; - private TimeSpan? diagnosticsLatencyThreshold; /// /// Latency Threshold to generate () with Request diagnostics in distributing Tracing.

/// If it is not set then by default it will generate () for query operation which are taking more than 500 ms and non-query operations taking more than 100 ms. ///
- public TimeSpan? DiagnosticsLatencyThreshold - { - get => this.diagnosticsLatencyThreshold; - set - { - if (this.EnableDiagnosticsTraceForAllRequests) - { - throw new ArgumentException("EnableDiagnosticsTraceForAllRequests can not be true along with DiagnosticsLatencyThreshold."); - } - - this.diagnosticsLatencyThreshold = value; - } - } - - /// - /// Set this flag as true if you want to generate () containing request diagnostics string for all the operations. - /// If this flag is true then, it won't honour value to generate diagnostic traces. - /// - public bool EnableDiagnosticsTraceForAllRequests - { - get => this.enableDiagnosticsTraceForAllRequests; - set - { - if (value && this.DiagnosticsLatencyThreshold != null) - { - throw new ArgumentException("EnableDiagnosticsTraceForAllRequests can not be true along with DiagnosticsLatencyThreshold."); - } - - this.enableDiagnosticsTraceForAllRequests = value; - } - } + public TimeSpan? DiagnosticsLatencyThreshold { get; set; } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml index a31ad6433d..3eb9468e57 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.BulkOperationsAsync.xml @@ -1602,7 +1602,7 @@ throttleClient.ClientOptions.EnableDistributedTracing = true; throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; ItemRequestOptions requestOptions = new ItemRequestOptions(); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.PointOperationsExceptionsAsync.xml b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.PointOperationsExceptionsAsync.xml index 019adb993e..d074dbb221 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.PointOperationsExceptionsAsync.xml +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/EndToEndTraceWriterBaselineTests.PointOperationsExceptionsAsync.xml @@ -175,7 +175,7 @@ throttleClient.ClientOptions.EnableDistributedTracing = true; throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; ItemRequestOptions requestOptions = new ItemRequestOptions(); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/EndToEndTraceWriterBaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/EndToEndTraceWriterBaselineTests.cs index aea21c9655..f64d289cfe 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/EndToEndTraceWriterBaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Tracing/EndToEndTraceWriterBaselineTests.cs @@ -57,17 +57,17 @@ public static async Task ClassInitAsync(TestContext context) client.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; bulkClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; miscCosmosClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; EndToEndTraceWriterBaselineTests.database = await client.CreateDatabaseAsync( @@ -984,7 +984,7 @@ public async Task PointOperationsExceptionsAsync() throttleClient.ClientOptions.EnableDistributedTracing = true; throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; ItemRequestOptions requestOptions = new ItemRequestOptions(); @@ -1271,7 +1271,7 @@ public async Task BulkOperationsAsync() throttleClient.ClientOptions.EnableDistributedTracing = true; throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions() { - EnableDiagnosticsTraceForAllRequests = true + DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0) }; ItemRequestOptions requestOptions = new ItemRequestOptions(); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosClientOptionsUnitTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosClientOptionsUnitTests.cs index 6078570d96..e39bb8d0f3 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosClientOptionsUnitTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosClientOptionsUnitTests.cs @@ -186,25 +186,6 @@ public void VerifyCosmosConfigurationPropertiesGetUpdated() Assert.AreEqual(portReuseMode, policy.PortReuseMode); Assert.IsTrue(policy.EnableTcpConnectionEndpointRediscovery); CollectionAssert.AreEqual(preferredLocations.ToArray(), policy.PreferredLocations.ToArray()); - - // Verify DiagnosticsLatencyThreshold - cosmosClientBuilder = new CosmosClientBuilder( - accountEndpoint: endpoint, - authKeyOrResourceToken: key); - var exception = Assert.ThrowsException(() => cosmosClientBuilder.WithConnectionModeDirect( - idleTcpConnectionTimeout, - openTcpConnectionTimeout, - maxRequestsPerTcpConnection, - maxTcpConnectionsPerEndpoint, - portReuseMode, - enableTcpConnectionEndpointRediscovery) - .WithApplicationPreferredRegions(preferredLocations) - .WithDistributingTracing(new DistributedTracingOptions - { - DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(100), - EnableDiagnosticsTraceForAllRequests = true - })); - Assert.AreEqual("EnableDiagnosticsTraceForAllRequests can not be true along with DiagnosticsLatencyThreshold.", exception.Message); } [TestMethod]