Răsfoiți Sursa

Linting, add more telemetry attributes

Mauricio Araujo 2 ani în urmă
părinte
comite
7eccdd4739
1 a modificat fișierele cu 11 adăugiri și 3 ștergeri
  1. 11 3
      internal/billing/stripe.go

+ 11 - 3
internal/billing/stripe.go

@@ -27,6 +27,10 @@ func (s *StripeBillingManager) CreateCustomer(ctx context.Context, userEmail str
 
 	stripe.Key = s.StripeSecretKey
 
+	telemetry.WithAttributes(span,
+		telemetry.AttributeKV{Key: "billing-id", Value: proj.BillingID},
+	)
+
 	if proj.BillingID == "" {
 		// Create customer if not exists
 		customerName := fmt.Sprintf("project_%s", proj.Name)
@@ -54,6 +58,10 @@ func (s *StripeBillingManager) DeleteCustomer(ctx context.Context, proj *models.
 
 	stripe.Key = s.StripeSecretKey
 
+	telemetry.WithAttributes(span,
+		telemetry.AttributeKV{Key: "billing-id", Value: proj.BillingID},
+	)
+
 	if proj.BillingID != "" {
 		params := &stripe.CustomerParams{}
 		_, err := customer.Del(proj.BillingID, params)
@@ -67,7 +75,7 @@ func (s *StripeBillingManager) DeleteCustomer(ctx context.Context, proj *models.
 
 // CheckPaymentEnabled will return true if the project has a payment method added, false otherwise
 func (s *StripeBillingManager) CheckPaymentEnabled(ctx context.Context, proj *models.Project) (paymentEnabled bool, err error) {
-	ctx, span := telemetry.NewSpan(ctx, "check-stripe-payment-enabled")
+	_, span := telemetry.NewSpan(ctx, "check-stripe-payment-enabled")
 	defer span.End()
 
 	stripe.Key = s.StripeSecretKey
@@ -189,9 +197,9 @@ func (s *StripeBillingManager) DeletePaymentMethod(ctx context.Context, paymentM
 	return nil
 }
 
-// GetPublishableKey is a no-op
+// GetPublishableKey returns the Stripe publishable key
 func (s *StripeBillingManager) GetPublishableKey(ctx context.Context) (key string) {
-	ctx, span := telemetry.NewSpan(ctx, "get-stripe-publishable-key")
+	_, span := telemetry.NewSpan(ctx, "get-stripe-publishable-key")
 	defer span.End()
 
 	return s.StripePublishableKey