Skip to content

Commit 72a01c0

Browse files
easyCZroboquat
authored andcommitted
[stripe] Check for err when reporting stripe requests completed metric
1 parent 8dc8bea commit 72a01c0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

components/usage/pkg/stripe/reporter.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ func reportStripeRequestStarted(resource string) {
6464
}
6565

6666
func reportStripeRequestCompleted(resource string, err error, took time.Duration) {
67-
code := "unknown"
68-
if stripeErr, ok := err.(*stripe.Error); ok {
69-
code = string(stripeErr.Code)
67+
code := "ok"
68+
if err != nil {
69+
code = "unknown"
70+
if stripeErr, ok := err.(*stripe.Error); ok {
71+
code = string(stripeErr.Code)
72+
}
7073
}
7174

7275
stripeClientRequestsCompletedSeconds.WithLabelValues(resource, code).Observe(took.Seconds())

0 commit comments

Comments
 (0)