Skip to content

Commit

Permalink
removed allr eference
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Nov 24, 2022
1 parent b24eeb9 commit 18894b4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 71 deletions.
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

0 comments on commit 18894b4

Please sign in to comment.