Skip to content

Commit

Permalink
add: elapse metric on ActionEvaluationPublisher
Browse files Browse the repository at this point in the history
  • Loading branch information
riemannulus committed Sep 22, 2023
1 parent 2c361ea commit 5c17083
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion NineChronicles.Headless/ActionEvaluationPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.Metrics;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -296,6 +297,8 @@ await _hub.BroadcastRenderBlockAsync(
{
try
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
ActionBase? pa = ev.Action is RewardGold
? null
: ev.Action;
Expand Down Expand Up @@ -361,8 +364,23 @@ await _hub.BroadcastRenderBlockAsync(
ev.Action.GetType(),
compressed.LongLength
);


var encodeElapsedMilliseconds = stopwatch.ElapsedMilliseconds;
await _hub.BroadcastRenderAsync(compressed);
stopwatch.Stop();
var broadcastElapsedMilliseconds = stopwatch.ElapsedMilliseconds - encodeElapsedMilliseconds;
Log
.ForContext("tag", "Metric")
.ForContext("subtag", "ActionEvaluationPublisherElapse")
.Information(
"[{ClientAddress}], #{BlockIndex}, {Action}," +
" {EncodeElapsedMilliseconds}, {BroadcastElapsedMilliseconds}, {TotalElapsedMilliseconds}",
_clientAddress,
ev.BlockIndex,
ev.Action.GetType(),
encodeElapsedMilliseconds,
broadcastElapsedMilliseconds,
encodeElapsedMilliseconds + broadcastElapsedMilliseconds);
}
catch (SerializationException se)
{
Expand Down

0 comments on commit 5c17083

Please sign in to comment.