watchtower/wtclient: export clientStats
This commit is contained in:
parent
159883665d
commit
4abadc82f3
@ -161,7 +161,7 @@ type TowerClient struct {
|
|||||||
chanCommitHeights map[lnwire.ChannelID]uint64
|
chanCommitHeights map[lnwire.ChannelID]uint64
|
||||||
|
|
||||||
statTicker *time.Ticker
|
statTicker *time.Ticker
|
||||||
stats clientStats
|
stats ClientStats
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
forceQuit chan struct{}
|
forceQuit chan struct{}
|
||||||
|
@ -2,50 +2,66 @@ package wtclient
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type clientStats struct {
|
// ClientStats is a collection of in-memory statistics of the actions the client
|
||||||
numTasksReceived int
|
// has performed since its creation.
|
||||||
numTasksAccepted int
|
type ClientStats struct {
|
||||||
numTasksIneligible int
|
// NumTasksReceived is the total number of backups that are pending to
|
||||||
numSessionsAcquired int
|
// be acknowledged by all active and exhausted watchtower sessions.
|
||||||
numSessionsExhausted int
|
NumTasksReceived int
|
||||||
|
|
||||||
|
// NumTasksAccepted is the total number of backups made to all active
|
||||||
|
// and exhausted watchtower sessions.
|
||||||
|
NumTasksAccepted int
|
||||||
|
|
||||||
|
// NumTasksIneligible is the total number of backups that all active and
|
||||||
|
// exhausted watchtower sessions have failed to acknowledge.
|
||||||
|
NumTasksIneligible int
|
||||||
|
|
||||||
|
// NumSessionsAcquired is the total number of new sessions made to
|
||||||
|
// watchtowers.
|
||||||
|
NumSessionsAcquired int
|
||||||
|
|
||||||
|
// NumSessionsExhausted is the total number of watchtower sessions that
|
||||||
|
// have been exhausted.
|
||||||
|
NumSessionsExhausted int
|
||||||
}
|
}
|
||||||
|
|
||||||
// taskReceived increments the number to backup requests the client has received
|
// taskReceived increments the number to backup requests the client has received
|
||||||
// from active channels.
|
// from active channels.
|
||||||
func (s *clientStats) taskReceived() {
|
func (s *ClientStats) taskReceived() {
|
||||||
s.numTasksReceived++
|
s.NumTasksReceived++
|
||||||
}
|
}
|
||||||
|
|
||||||
// taskAccepted increments the number of tasks that have been assigned to active
|
// taskAccepted increments the number of tasks that have been assigned to active
|
||||||
// session queues, and are awaiting upload to a tower.
|
// session queues, and are awaiting upload to a tower.
|
||||||
func (s *clientStats) taskAccepted() {
|
func (s *ClientStats) taskAccepted() {
|
||||||
s.numTasksAccepted++
|
s.NumTasksAccepted++
|
||||||
}
|
}
|
||||||
|
|
||||||
// taskIneligible increments the number of tasks that were unable to satisfy the
|
// taskIneligible increments the number of tasks that were unable to satisfy the
|
||||||
// active session queue's policy. These can potentially be retried later, but
|
// active session queue's policy. These can potentially be retried later, but
|
||||||
// typically this means that the balance created dust outputs, so it may not be
|
// typically this means that the balance created dust outputs, so it may not be
|
||||||
// worth backing up at all.
|
// worth backing up at all.
|
||||||
func (s *clientStats) taskIneligible() {
|
func (s *ClientStats) taskIneligible() {
|
||||||
s.numTasksIneligible++
|
s.NumTasksIneligible++
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionAcquired increments the number of sessions that have been successfully
|
// sessionAcquired increments the number of sessions that have been successfully
|
||||||
// negotiated by the client during this execution.
|
// negotiated by the client during this execution.
|
||||||
func (s *clientStats) sessionAcquired() {
|
func (s *ClientStats) sessionAcquired() {
|
||||||
s.numSessionsAcquired++
|
s.NumSessionsAcquired++
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionExhausted increments the number of session that have become full as a
|
// sessionExhausted increments the number of session that have become full as a
|
||||||
// result of accepting backup tasks.
|
// result of accepting backup tasks.
|
||||||
func (s *clientStats) sessionExhausted() {
|
func (s *ClientStats) sessionExhausted() {
|
||||||
s.numSessionsExhausted++
|
s.NumSessionsExhausted++
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human readable summary of the client's metrics.
|
// String returns a human readable summary of the client's metrics.
|
||||||
func (s clientStats) String() string {
|
func (s ClientStats) String() string {
|
||||||
return fmt.Sprintf("tasks(received=%d accepted=%d ineligible=%d) "+
|
return fmt.Sprintf("tasks(received=%d accepted=%d ineligible=%d) "+
|
||||||
"sessions(acquired=%d exhausted=%d)", s.numTasksReceived,
|
"sessions(acquired=%d exhausted=%d)", s.NumTasksReceived,
|
||||||
s.numTasksAccepted, s.numTasksIneligible, s.numSessionsAcquired,
|
s.NumTasksAccepted, s.NumTasksIneligible, s.NumSessionsAcquired,
|
||||||
s.numSessionsExhausted)
|
s.NumSessionsExhausted)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user