Skip to content

Commit

Permalink
update contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh1007 committed Sep 1, 2023
1 parent 26e4ca6 commit fb3ae09
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,18 @@ internal Microsoft.Azure.Cosmos.CosmosClient CreateCosmosClient(string accountKe
MaxRetryAttemptsOnRateLimitedRequests = 0,
MaxRequestsPerTcpConnection = this.MaxRequestsPerTcpConnection,
MaxTcpConnectionsPerEndpoint = this.MaxTcpConnectionsPerEndpoint,
EnableClientTelemetry = this.EnableClientTelemetry
CosmosClientTelemetryOptions = new Microsoft.Azure.Cosmos.CosmosClientTelemetryOptions()
{
EnableSendingMetricsToService = this.EnableTelemetry,
DisableDistributedTracing = !this.EnableDistributedTracing
}
};

if (!string.IsNullOrWhiteSpace(this.ConsistencyLevel))
{
clientOptions.ConsistencyLevel = (Microsoft.Azure.Cosmos.ConsistencyLevel)Enum.Parse(typeof(Microsoft.Azure.Cosmos.ConsistencyLevel), this.ConsistencyLevel, ignoreCase: true);
}

clientOptions.IsDistributedTracingEnabled = this.EnableDistributedTracing;

return new Microsoft.Azure.Cosmos.CosmosClient(
this.EndPoint,
accountKey,
Expand Down
5 changes: 4 additions & 1 deletion Microsoft.Azure.Cosmos.Samples/Tools/CTL/CTLConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ internal CosmosClient CreateCosmosClient()
CosmosClientOptions clientOptions = new CosmosClientOptions()
{
ApplicationName = CTLConfig.UserAgentSuffix,
EnableClientTelemetry = this.EnableClientTelemetry
CosmosClientTelemetryOptions = new CosmosClientTelemetryOptions()
{
EnableSendingMetricsToService = true,
}
};

if (this.UseGatewayMode)
Expand Down
6 changes: 6 additions & 0 deletions Microsoft.Azure.Cosmos.Samples/Tools/CTL/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ await scenario.InitializeAsync(

logger.LogInformation("Initialization completed.");

if(client.ClientOptions.CosmosClientTelemetryOptions.EnableSendingMetricsToService) {
logger.LogInformation("Telemetry is enabled for CTL.");
} else {
logger.LogInformation("Telemetry is disabled for CTL.");
}

List<Task> tasks = new List<Task>
{
scenario.RunAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3969,9 +3969,14 @@
maxRetryWaitTimeOnThrottledRequests: TimeSpan.FromSeconds(1),
maxRetryAttemptsOnThrottledRequests: 3)
.WithBulkExecution(true)
.WithDistributedTracingOptions(new DistributedTracingOptions()
.WithClientTelemetryOptions(new CosmosClientTelemetryOptions()
{
LatencyThresholdForDiagnosticEvent = TimeSpan.FromMilliseconds(0)
DisableDistributedTracing = false,
CosmosThresholdOptions = new CosmosThresholdOptions()
{
PointOperationLatencyThreshold = TimeSpan.FromMilliseconds(0),
NonPointOperationLatencyThreshold = TimeSpan.FromMilliseconds(0)
}
})
.WithTransportClientHandlerFactory(transportClient => new TransportClientWrapper(
transportClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,14 @@
Guid exceptionActivityId = Guid.NewGuid();
using CosmosClient throttleClient = TestCommon.CreateCosmosClient(builder =>
builder
.WithDistributedTracingOptions(new DistributedTracingOptions()
.WithClientTelemetryOptions(new CosmosClientTelemetryOptions()
{
LatencyThresholdForDiagnosticEvent = TimeSpan.FromMilliseconds(0)
DisableDistributedTracing = false,
CosmosThresholdOptions = new CosmosThresholdOptions()
{
PointOperationLatencyThreshold = TimeSpan.FromMilliseconds(0),
NonPointOperationLatencyThreshold = TimeSpan.FromMilliseconds(0)
}
})
.WithThrottlingRetryOptions(
maxRetryWaitTimeOnThrottledRequests: TimeSpan.FromSeconds(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@
<ATTRIBUTE key="tcp.sub_status_code">0</ATTRIBUTE>
<ATTRIBUTE key="tcp.status_code">201</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Request" operationName="RequestAsync" displayName="Read Database">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.17.0</ATTRIBUTE>
<ATTRIBUTE key="tcp.uri">Some Value</ATTRIBUTE>
<ATTRIBUTE key="tcp.sub_status_code">0</ATTRIBUTE>
<ATTRIBUTE key="tcp.status_code">404</ATTRIBUTE>
</ACTIVITY>
<EVENT name="LatencyOverThreshold" />
<EVENT name="LatencyOverThreshold" />
</OTelActivities></Output>
</Result>
Expand Down

0 comments on commit fb3ae09

Please sign in to comment.