From e3bcf95247e71f1112781a4cca548e3e8b7a78f8 Mon Sep 17 00:00:00 2001 From: Samantha Date: Wed, 29 Jan 2025 13:57:37 -0500 Subject: [PATCH] Cover updates and range over contacts --- ra/ra.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ra/ra.go b/ra/ra.go index 19b673d1bcd..4f1a6339687 100644 --- a/ra/ra.go +++ b/ra/ra.go @@ -127,7 +127,7 @@ type RegistrationAuthorityImpl struct { mustStapleRequestsCounter *prometheus.CounterVec // TODO(#7966): Remove once the rate of registrations with contacts has been // determined. - newRegWithContactCounter prometheus.Counter + newRegWithContactCounter *prometheus.CounterVec } var _ rapb.RegistrationAuthorityServer = (*RegistrationAuthorityImpl)(nil) @@ -250,10 +250,10 @@ func NewRegistrationAuthorityImpl( // TODO(#7966): Remove once the rate of registrations with contacts has been // determined. - newRegWithContactCounter := prometheus.NewCounter(prometheus.CounterOpts{ + newRegWithContactCounter := prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "new_registrations_with_contacts", - Help: "A counter of new registrations with contacts", - }) + Help: "A counter of new registrations with contacts, labeled by one of new=[bool], update=[bool]", + }, []string{"new", "update"}) stats.MustRegister(newRegWithContactCounter) issuersByNameID := make(map[issuance.NameID]*issuance.Certificate) @@ -427,12 +427,14 @@ func (ra *RegistrationAuthorityImpl) NewRegistration(ctx context.Context, reques return nil, err } - ra.newRegCounter.Inc() // TODO(#7966): Remove once the rate of registrations with contacts has been // determined. - if len(request.Contact) > 0 { - ra.newRegWithContactCounter.Inc() + for range request.Contact { + ra.newRegWithContactCounter.With(prometheus.Labels{"new": "true"}).Inc() } + + ra.newRegCounter.Inc() + return res, nil } @@ -1291,6 +1293,12 @@ func (ra *RegistrationAuthorityImpl) UpdateRegistrationContact(ctx context.Conte return nil, fmt.Errorf("invalid contact: %w", err) } + // TODO(#7966): Remove once the rate of registrations with contacts has + // been determined. + for range req.Contacts { + ra.newRegWithContactCounter.With(prometheus.Labels{"update": "true"}).Inc() + } + update, err := ra.SA.UpdateRegistrationContact(ctx, &sapb.UpdateRegistrationContactRequest{ RegistrationID: req.RegistrationID, Contacts: req.Contacts,