@@ -23,13 +23,15 @@ var (
23
23
[]string {"status" },
24
24
)
25
25
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 (
29
30
prometheus.CounterOpts {
30
31
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 " ,
32
33
},
34
+ []string {"status" },
33
35
)
34
36
35
37
// paymentAttempts is a histogram for visualizing what portion of
@@ -164,12 +166,13 @@ func processPaymentUpdate(payment *lnrpc.Payment) {
164
166
status = "unknown"
165
167
}
166
168
169
+ // Increment metrics with proper label.
167
170
totalPayments .WithLabelValues (status ).Inc ()
171
+
168
172
attemptCount := len (payment .Htlcs )
173
+ totalHTLCAttempts .WithLabelValues (status ).Add (float64 (attemptCount ))
169
174
170
- totalHTLCAttempts .Add (float64 (attemptCount ))
171
175
paymentAttempts .Observe (float64 (attemptCount ))
172
-
173
176
paymentLogger .Debugf ("Payment %s updated: status=%s, %d attempts" ,
174
177
payment .PaymentHash , status , attemptCount )
175
178
}
0 commit comments