Skip to content

Commit

Permalink
feat: Add Processing Time stat field (#218)
Browse files Browse the repository at this point in the history
Co-authored-by: James Rodewig <[email protected]>
  • Loading branch information
cynicaljoy and jrodewig authored Nov 8, 2024
1 parent 74e08fb commit cab2e30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Fauna.Test/Integration.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,8 @@ await _client.QueryAsync(
int pages = 0;
await foreach (var page in feed)
{
if (page.HasNext)
{
Assert.AreEqual(pageSize, page.Events.Count);
}
if (page.Events.Count > 0) Assert.NotNull(page.Events[0].Stats.ProcessingTimeMs);
if (page.HasNext) Assert.AreEqual(pageSize, page.Events.Count);

pages++;
}
Expand Down
7 changes: 7 additions & 0 deletions Fauna/Core/QueryStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public readonly struct QueryStats
[JsonPropertyName(Stats_RateLimitsHit)]
public List<string> RateLimitsHit { get; init; }

/// <summary>
/// Processing time in milliseconds. Only returned on Events.
/// </summary>
[JsonPropertyName(Stats_ProcessingTimeMs)]
public int? ProcessingTimeMs { get; init; }

/// <summary>
/// Returns a string representation of the query statistics.
/// </summary>
Expand All @@ -65,6 +71,7 @@ public override string ToString()
return $"compute: {ComputeOps}, read: {ReadOps}, write: {WriteOps}, " +
$"queryTime: {QueryTimeMs}, retries: {ContentionRetries}, " +
$"storageRead: {StorageBytesRead}, storageWrite: {StorageBytesWrite}, " +
$"{(ProcessingTimeMs.HasValue ? $"processingTime: {ProcessingTimeMs}, " : "")}" +
$"limits: [{string.Join(',', RateLimitsHit)}]";
}
}
5 changes: 5 additions & 0 deletions Fauna/Core/ResponseFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ internal readonly struct ResponseFields
/// </summary>
public const string Stats_RateLimitsHit = "rate_limits_hit";

/// <summary>
/// Field name for the processing time in milliseconds.
/// </summary>
public const string Stats_ProcessingTimeMs = "processing_time_ms";

#endregion

#region "error" block
Expand Down

0 comments on commit cab2e30

Please sign in to comment.