Skip to content

Commit 172df29

Browse files
committed
add type to local/remote error metrics
1 parent aff16b2 commit 172df29

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ object Monitoring {
8686
val Direction = "direction"
8787
val Event = "event"
8888
val Fatal = "fatal"
89+
val ErrorType = "error-type"
8990
val Origin = "origin"
9091
val State = "state"
9192
val CommitmentFormat = "commitment-format"

eclair-core/src/main/scala/fr/acinq/eclair/db/DbEventHandler.scala

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import fr.acinq.eclair.db.DbEventHandler.ChannelEvent
3030
import fr.acinq.eclair.payment.Monitoring.{Metrics => PaymentMetrics, Tags => PaymentTags}
3131
import fr.acinq.eclair.payment._
3232
import fr.acinq.eclair.{Logs, NodeParams, TimestampMilli}
33+
import kamon.tag.TagSet
3334

3435
/**
3536
* This actor sits at the interface between our event stream and the database.
@@ -112,10 +113,39 @@ class DbEventHandler(nodeParams: NodeParams) extends Actor with DiagnosticActorL
112113
// The first pattern matching level is to ignore some errors, the second level is to separate between different kind of errors.
113114
e.error match {
114115
case LocalError(_: CannotAffordFees) => () // will be thrown at each new block if our balance is too low to update the commitment fee
115-
case _ => e.error match {
116-
case LocalError(_) => ChannelMetrics.ChannelErrors.withTag(ChannelTags.Origin, ChannelTags.Origins.Local).withTag(ChannelTags.Fatal, value = e.isFatal).increment()
117-
case RemoteError(_) => ChannelMetrics.ChannelErrors.withTag(ChannelTags.Origin, ChannelTags.Origins.Remote).increment()
116+
case _ =>
117+
val tags =
118+
e.error match {
119+
case LocalError(t) => TagSet.Empty
120+
.withTag(ChannelTags.Origin, ChannelTags.Origins.Local)
121+
.withTag(ChannelTags.Fatal, value = e.isFatal)
122+
.withTag(ChannelTags.ErrorType, t.getClass.getSimpleName)
123+
case RemoteError(msg) =>
124+
val errorType = msg.toAscii match {
125+
case ascii if ascii.equals("Awaiting unilateral close") => ascii
126+
case ascii if ascii.equals("internal error") => ascii
127+
case ascii if ascii.equals("We can't be together anymore.") => ascii
128+
case ascii if ascii.equals("forced local commit") => ascii
129+
case ascii if ascii.equals("invalid revocation") => ascii
130+
case ascii if ascii.equals("Channel open canceled by us") => ascii
131+
case ascii if ascii.equals("Number of pending channels exceed maximum") => ascii
132+
case ascii if ascii.equals("channel rejected") => ascii
133+
case ascii if ascii.equals("funding failed due to internal error") => ascii
134+
case ascii if ascii.equals("unable to resume channel, recovery required") => ascii
135+
case ascii if ascii.equals("Channel is closed and forgotten") => ascii
136+
case ascii if ascii.equals("unknown channel") => ascii
137+
case ascii if ascii.startsWith("funding tx has been spent") => "funding tx has been spent"
138+
case ascii if ascii.startsWith("invalid commitment signature") => "invalid commitment signature"
139+
case ascii if ascii.startsWith("channeld: received ERROR channel") => "channeld: received ERROR channel"
140+
case ascii if ascii.startsWith("Witnesses lower effective feerate below agreed upon rate") => "Witnesses lower effective feerate below agreed upon rate"
141+
case _ => "other"
142+
}
143+
TagSet.Empty
144+
.withTag(ChannelTags.Origin, ChannelTags.Origins.Remote)
145+
.withTag(ChannelTags.Fatal, value = true) // remote errors are always fatal
146+
.withTag(ChannelTags.ErrorType, errorType)
118147
}
148+
ChannelMetrics.ChannelErrors.withTags(tags).increment()
119149
}
120150

121151
case e: ChannelStateChanged =>

0 commit comments

Comments
 (0)