Skip to content

Commit

Permalink
monitor traffic shaping
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 25, 2024
1 parent aea879f commit 7ad53ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/scala/Monitor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,5 @@ object Monitor:
val step = Kamon.gauge("connector.flush.config.step").withoutTags()
val interval = Kamon.gauge("connector.flush.config.interval").withoutTags()
val maxDelay = Kamon.gauge("connector.flush.config.maxDelay").withoutTags()
val qSize = Kamon.histogram("connector.flush.qSize").withoutTags()
val channelsToFlush = Kamon.histogram("connector.flush.channelsToFlush").withoutTags()
6 changes: 5 additions & 1 deletion src/main/scala/netty/ActorChannelConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ final private class ActorChannelConnector(
flushQ.add(channel)

private def flush(): Unit =
val qSize = flushQ.size
val maxDelayFactor = maxDelay.get().toDouble / interval.get()
var channelsToFlush = step.get().atLeast((flushQ.size * maxDelayFactor).toInt)
var channelsToFlush = step.get().atLeast((qSize * maxDelayFactor).toInt)

monitor.qSize.record(qSize)
monitor.channelsToFlush.record(channelsToFlush)

while channelsToFlush > 0 do
Option(flushQ.poll()) match
Expand Down

0 comments on commit 7ad53ab

Please sign in to comment.