@@ -23,13 +23,15 @@ var (
2323 []string {"status" },
2424 )
2525
26- // totalHTLCAttempts is a simple counter which, in combination with the
27- // payment counter, permits tracking the number of attempts per payment.
28- totalHTLCAttempts = prometheus .NewCounter (
26+ // totalHTLCAttempts tracks the number of HTLC attempts made based on
27+ // the payment status (success or fail). When combined with the payment
28+ // counter, this permits tracking the number of attempts per payment.
29+ totalHTLCAttempts = prometheus .NewCounterVec (
2930 prometheus.CounterOpts {
3031 Name : "lnd_total_htlc_attempts" ,
31- Help : "Total number of HTLC attempts across all payments" ,
32+ Help : "Total number of HTLC attempts across all payments, labeled by final payment status " ,
3233 },
34+ []string {"status" },
3335 )
3436
3537 // paymentAttempts is a histogram for visualizing what portion of
@@ -164,12 +166,13 @@ func processPaymentUpdate(payment *lnrpc.Payment) {
164166 status = "unknown"
165167 }
166168
169+ // Increment metrics with proper label.
167170 totalPayments .WithLabelValues (status ).Inc ()
171+
168172 attemptCount := len (payment .Htlcs )
173+ totalHTLCAttempts .WithLabelValues (status ).Add (float64 (attemptCount ))
169174
170- totalHTLCAttempts .Add (float64 (attemptCount ))
171175 paymentAttempts .Observe (float64 (attemptCount ))
172-
173176 paymentLogger .Debugf ("Payment %s updated: status=%s, %d attempts" ,
174177 payment .PaymentHash , status , attemptCount )
175178}
0 commit comments