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

feat: Add Processing Time stat field #218

Merged
merged 2 commits into from
Nov 8, 2024
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
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
Loading