Skip to content

Commit

Permalink
fix(eqx stats): Handle newest/oldest when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Aug 1, 2024
1 parent eb0f537 commit f4e0b8d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/Equinox.Tool/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,11 @@ module CosmosStats =
ops |> Seq.map (fun (name, sql) -> async {
let! res = Microsoft.Azure.Cosmos.QueryDefinition sql
|> container.GetItemQueryIterator<int64>
|> Query.enum_ log container "Stat" null LogEventLevel.Debug |> TaskSeq.head |> Async.AwaitTaskCorrect
match name with
| "Oldest" | "Newest" -> log.Information("{stat,-10}: {result,13} ({d:u})", name, res, DateTime.UnixEpoch.AddSeconds(float res))
| _ -> log.Information("{stat,-10}: {result,13:N0}", name, res) })
|> Query.enum_ log container "Stat" null LogEventLevel.Debug |> TaskSeq.tryHead |> Async.AwaitTaskCorrect
match name, res with
| ("Oldest" | "Newest"), Some res -> log.Information("{stat,-10}: {result,13} ({d:u})", name, res, DateTime.UnixEpoch.AddSeconds(float res))
| _, Some res -> log.Information("{stat,-10}: {result,13:N0}", name, res)
| _, None -> () }) // handle no Oldest/Newest not producing a result
|> if inParallel then Async.Parallel else Async.Sequential
|> Async.Ignore<unit[]>
| StatsParameters.Dynamo sp -> async {
Expand Down

0 comments on commit f4e0b8d

Please sign in to comment.