Skip to content

Commit

Permalink
Diagnostics: Adds Processor count into CosmosDiagnostics (#3194)
Browse files Browse the repository at this point in the history
Adds Processor count into Client configuration section of diagnostics. Insufficient number of processors can cause high latency, so this will help identify those situations.
  • Loading branch information
imanvt authored May 19, 2022
1 parent cda62eb commit 17e9f7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public ClientConfigurationTraceDatum(CosmosClientContext cosmosClientContext, Da
this.cachedNumberOfActiveClient = CosmosClient.NumberOfActiveClients;
this.cachedUserAgentString = this.UserAgentContainer.UserAgent;
this.cachedSerializedJson = this.GetSerializedDatum();
this.ProcessorCount = Environment.ProcessorCount;
}

public DateTime ClientCreatedDateTimeUtc { get; }
Expand All @@ -44,6 +45,8 @@ public ClientConfigurationTraceDatum(CosmosClientContext cosmosClientContext, Da

public ConsistencyConfig ConsistencyConfig { get; }

public int ProcessorCount { get; }

public ReadOnlyMemory<byte> SerializedJson
{
get
Expand Down Expand Up @@ -105,6 +108,9 @@ private ReadOnlyMemory<byte> GetSerializedDatum()

jsonTextWriter.WriteFieldName("ConsistencyConfig");
jsonTextWriter.WriteStringValue(this.ConsistencyConfig.ToString());
jsonTextWriter.WriteFieldName("ProcessorCount");
jsonTextWriter.WriteNumber64Value(this.ProcessorCount);

jsonTextWriter.WriteObjectEnd();

return jsonTextWriter.GetResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public async Task CachedSerializationTest()
trace = ((CosmosTraceDiagnostics)response.Diagnostics).Value;
clientConfigurationTraceDatum = (ClientConfigurationTraceDatum)trace.Data["Client Configuration"];
Assert.IsNotNull(clientConfigurationTraceDatum.SerializedJson);
Assert.AreEqual(clientConfigurationTraceDatum.ProcessorCount, Environment.ProcessorCount);
}
}
}

0 comments on commit 17e9f7b

Please sign in to comment.