Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Integration: Removed EnableDiagnosticsTraceForAllRequests Config #3581

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,11 @@ internal sealed class DistributedTracingOptions
/// Default Latency threshold for QUERY operation
/// </summary>
internal static readonly TimeSpan DefaultQueryTimeoutThreshold = TimeSpan.FromMilliseconds(500);
private bool enableDiagnosticsTraceForAllRequests;
private TimeSpan? diagnosticsLatencyThreshold;

/// <summary>
/// Latency Threshold to generate (<see cref="System.Diagnostics.Tracing.EventSource"/>) with Request diagnostics in distributing Tracing.<br></br>
/// If it is not set then by default it will generate (<see cref="System.Diagnostics.Tracing.EventSource"/>) for query operation which are taking more than 500 ms and non-query operations taking more than 100 ms.
/// </summary>
public TimeSpan? DiagnosticsLatencyThreshold
{
get => this.diagnosticsLatencyThreshold;
set
{
if (this.EnableDiagnosticsTraceForAllRequests)
{
throw new ArgumentException("EnableDiagnosticsTraceForAllRequests can not be true along with DiagnosticsLatencyThreshold.");
}

this.diagnosticsLatencyThreshold = value;
}
}

/// <summary>
/// Set this flag as true if you want to generate (<see cref="System.Diagnostics.Tracing.EventSource"/>) containing request diagnostics string for all the operations.
/// If this flag is true then, it won't honour <see cref="DiagnosticsLatencyThreshold"/> value to generate diagnostic traces.
/// </summary>
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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@
throttleClient.ClientOptions.EnableDistributedTracing = true;
throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions()
{
EnableDiagnosticsTraceForAllRequests = true
DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0)
};

ItemRequestOptions requestOptions = new ItemRequestOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
throttleClient.ClientOptions.EnableDistributedTracing = true;
throttleClient.ClientOptions.DistributedTracingOptions = new DistributedTracingOptions()
{
EnableDiagnosticsTraceForAllRequests = true
DiagnosticsLatencyThreshold = TimeSpan.FromMilliseconds(0)
};

ItemRequestOptions requestOptions = new ItemRequestOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentException>(() => 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]
Expand Down