Skip to content

Commit 6f6c458

Browse files
authored
Add metrics on channels processing time (#1826)
It's similar with built-in akka metrics, but with message-type granularity.
1 parent 4dc2910 commit 6f6c458

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package fr.acinq.eclair.channel
1818

1919
import akka.actor.typed.scaladsl.Behaviors
2020
import akka.actor.typed.scaladsl.adapter.{ClassicActorContextOps, TypedActorRefOps, actorRefAdapter}
21-
import akka.actor.{ActorContext, ActorRef, FSM, OneForOneStrategy, PossiblyHarmful, Props, Status, SupervisorStrategy, typed}
21+
import akka.actor.{Actor, ActorContext, ActorRef, FSM, OneForOneStrategy, PossiblyHarmful, Props, Status, SupervisorStrategy, typed}
2222
import akka.event.Logging.MDC
2323
import akka.pattern.pipe
2424
import fr.acinq.bitcoin.Crypto.{PrivateKey, PublicKey}
@@ -30,6 +30,7 @@ import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher
3030
import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher._
3131
import fr.acinq.eclair.blockchain.bitcoind.rpc.ExtendedBitcoinClient
3232
import fr.acinq.eclair.channel.Helpers.{Closing, Funding}
33+
import fr.acinq.eclair.channel.Monitoring.Metrics.ProcessMessage
3334
import fr.acinq.eclair.channel.Monitoring.{Metrics, Tags}
3435
import fr.acinq.eclair.channel.TxPublisher.{PublishRawTx, PublishTx, SetChannelId, SignAndPublishTx}
3536
import fr.acinq.eclair.crypto.ShaChain
@@ -2557,6 +2558,12 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
25572558
// we let the peer decide what to do
25582559
override val supervisorStrategy = OneForOneStrategy(loggingEnabled = true) { case _ => SupervisorStrategy.Escalate }
25592560

2561+
override def aroundReceive(receive: Actor.Receive, msg: Any): Unit = {
2562+
KamonExt.time(ProcessMessage.withTag("MessageType", msg.getClass.getSimpleName)) {
2563+
super.aroundReceive(receive, msg)
2564+
}
2565+
}
2566+
25602567
initialize()
25612568

25622569
}

eclair-core/src/main/scala/fr/acinq/eclair/channel/Monitoring.scala

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ object Monitoring {
3131
val HtlcValueInFlightGlobal = Kamon.gauge("channels.htlc-value-in-flight-global", "Global HTLC value in flight across all channels")
3232
val LocalFeeratePerKw = Kamon.gauge("channels.local-feerate-per-kw")
3333
val RemoteFeeratePerKw = Kamon.histogram("channels.remote-feerate-per-kw")
34+
val ProcessMessage = Kamon.timer("channels.messages-processed")
3435

3536
def recordHtlcsInFlight(remoteSpec: CommitmentSpec, previousRemoteSpec: CommitmentSpec): Unit = {
3637
for (direction <- Tags.Directions.Incoming :: Tags.Directions.Outgoing :: Nil) {

0 commit comments

Comments
 (0)