Skip to content

Commit

Permalink
Fix RU breakdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed May 3, 2022
1 parent 33bec18 commit 0299309
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Equinox.DynamoStore/DynamoStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ module Log =
"Prune", Stats.LogSink.Prune
"Delete", Stats.LogSink.Delete
"Trim", Stats.LogSink.Trim ]
let mutable rows, totalCount, totalRRu, totalWru, totalMs = 0, 0L, 0., 0L
let mutable rows, totalCount, totalRRu, totalWRu, totalMs = 0, 0L, 0., 0., 0L
let logActivity name count ru lat =
let aru, ams = (if count = 0L then Double.NaN else ru/float count), (if count = 0L then Double.NaN else float lat/float count)
let rut = match name with "Read" | "Prune" -> totalRRu <- totalRRu + ru; 'R' else totalWRu <- totalWRu + ru; 'W'
log.Information("{name}: {count:n0} requests costing {ru:n0}{rut}RU (average: {avgRu:n1}); Average latency: {lat:n0}ms",
let rut = match name with "TOTAL" -> "" | "Read" | "Prune" -> totalRRu <- totalRRu + ru; "R" | _ -> totalWRu <- totalWRu + ru; "W"
log.Information("{name}: {count:n0} requests costing {ru:n0}{rut:l}RU (average: {avgRu:n1}); Average latency: {lat:n0}ms",
name, count, ru, rut, aru, ams)
for name, stat in stats do
if stat.count <> 0L then
Expand All @@ -318,7 +318,7 @@ module Log =
rows <- rows + 1
// Yes, there's a minor race here between the use of the values and the reset
let duration = Stats.LogSink.Restart()
if rows > 1 then logActivity "TOTAL" totalCount totalRu totalMs
if rows > 1 then logActivity "TOTAL" totalCount (totalRRu + totalWRu) totalMs
let measures : (string * (TimeSpan -> float)) list = [ "s", fun x -> x.TotalSeconds(*; "m", fun x -> x.TotalMinutes; "h", fun x -> x.TotalHours*) ]
let logPeriodicRate name count rru wru = log.Information("rp{name} {count:n0} = ~{rru:n1}R/{wru:n1}W RU", name, count, rru, wru)
for uom, f in measures do let d = f duration in if d <> 0. then logPeriodicRate uom (float totalCount/d |> int64) (totalRRu/d) (totalWRu/d)
Expand Down

0 comments on commit 0299309

Please sign in to comment.