routing: track real-time payment and attempt counts

These metrics can serve as the basis for computing
average payment throughput or average number of attempts
per payment.
This commit is contained in:
Calvin Zachman 2025-02-20 10:36:23 -06:00
parent 951849709b
commit 4559fafad6
No known key found for this signature in database
GPG key ID: 52AAA845E345D42E
2 changed files with 8 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/monitoring"
"github.com/lightningnetwork/lnd/multimutex" "github.com/lightningnetwork/lnd/multimutex"
"github.com/lightningnetwork/lnd/queue" "github.com/lightningnetwork/lnd/queue"
) )
@ -191,6 +192,9 @@ func (p *controlTower) InitPayment(paymentHash lntypes.Hash,
return err return err
} }
// Observe the creation of a new payment.
monitoring.IncrementPaymentCount()
// Take lock before querying the db to prevent missing or duplicating // Take lock before querying the db to prevent missing or duplicating
// an update. // an update.
p.paymentsMtx.Lock(paymentHash) p.paymentsMtx.Lock(paymentHash)

View file

@ -15,6 +15,7 @@ import (
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/monitoring"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/routing/shards" "github.com/lightningnetwork/lnd/routing/shards"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"
@ -596,6 +597,9 @@ func (p *paymentLifecycle) registerAttempt(rt *route.Route,
p.identifier, &attempt.HTLCAttemptInfo, p.identifier, &attempt.HTLCAttemptInfo,
) )
// Observe a new HTLC attempt for the payment.
monitoring.IncrementHTLCAttemptCount()
return attempt, err return attempt, err
} }