Skip to content

Commit

Permalink
Better tracking of channels count metric (#1369)
Browse files Browse the repository at this point in the history
Track all channel states (cardinality shouldn't be too high).
Prevent duplicate transactions that messed up the gauge.
  • Loading branch information
t-bast authored Apr 10, 2020
1 parent 7a5dbfd commit 5fe6f67
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
14 changes: 3 additions & 11 deletions eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
// we pass these to helpers classes so that they have the logging context
implicit def implicitLog: akka.event.DiagnosticLoggingAdapter = diagLog

Metrics.ChannelsCount.withoutTags().increment()

// we assume that the peer is the channel's parent
private val peer = context.parent
// the last active connection we are aware of; note that the peer manages connections and asynchronously notifies
Expand Down Expand Up @@ -1384,7 +1382,6 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
case _ =>
}
log.info("shutting down")
Metrics.ChannelsCount.withoutTags().decrement()
stop(FSM.Normal)

case Event(MakeFundingTxResponse(fundingTx, _, _), _) =>
Expand Down Expand Up @@ -1691,7 +1688,6 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
// channel is closed, scheduling this actor for self destruction
context.system.scheduler.scheduleOnce(10 seconds, self, 'shutdown)
}

if (nextState == OFFLINE) {
// we can cancel the timer, we are not expecting anything when disconnected
cancelTimer(RevocationTimeout.toString)
Expand Down Expand Up @@ -1739,13 +1735,9 @@ class Channel(val nodeParams: NodeParams, val wallet: EclairWallet, remoteNodeId
}

onTransition {
case _ -> OFFLINE => Metrics.ChannelsCount.withTag(Tags.State, Tags.States.Offline).increment()
case OFFLINE -> _ => Metrics.ChannelsCount.withTag(Tags.State, Tags.States.Offline).decrement()
}

onTransition {
case _ -> CLOSING => Metrics.ChannelsCount.withTag(Tags.State, Tags.States.Closing).increment()
case CLOSING -> _ => Metrics.ChannelsCount.withTag(Tags.State, Tags.States.Closing).decrement()
case state -> nextState if state != nextState =>
if (state != WAIT_FOR_INIT_INTERNAL) Metrics.ChannelsCount.withTag(Tags.State, state.toString).decrement()
if (nextState != WAIT_FOR_INIT_INTERNAL) Metrics.ChannelsCount.withTag(Tags.State, nextState.toString).increment()
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ object Monitoring {
val Closed = "closed"
}

object States {
val Offline = "offline"
val Closing = "closing"
}

object Origins {
val Local = "local"
val Remote = "remote"
Expand Down

0 comments on commit 5fe6f67

Please sign in to comment.