From 1d2601515bd6b7051a8d9e095549d2a3739269c4 Mon Sep 17 00:00:00 2001 From: Samantha Frank Date: Mon, 3 Feb 2025 11:50:43 -0500 Subject: [PATCH] RA: Count new registrations with contacts (#7984) Adding a temporary metric to estimate the rate of new contacts for accounts. Part of #7966 --- ra/ra.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ra/ra.go b/ra/ra.go index 4b5e8dceb..916d14109 100644 --- a/ra/ra.go +++ b/ra/ra.go @@ -125,6 +125,9 @@ type RegistrationAuthorityImpl struct { certCSRMismatch prometheus.Counter pauseCounter *prometheus.CounterVec mustStapleRequestsCounter *prometheus.CounterVec + // TODO(#7966): Remove once the rate of registrations with contacts has been + // determined. + newOrUpdatedContactCounter *prometheus.CounterVec } var _ rapb.RegistrationAuthorityServer = (*RegistrationAuthorityImpl)(nil) @@ -245,6 +248,14 @@ func NewRegistrationAuthorityImpl( }, []string{"allowlist"}) stats.MustRegister(mustStapleRequestsCounter) + // TODO(#7966): Remove once the rate of registrations with contacts has been + // determined. + newOrUpdatedContactCounter := prometheus.NewCounterVec(prometheus.CounterOpts{ + Name: "new_or_updated_contact", + Help: "A counter of new or updated contacts, labeled by new=[bool]", + }, []string{"new"}) + stats.MustRegister(newOrUpdatedContactCounter) + issuersByNameID := make(map[issuance.NameID]*issuance.Certificate) for _, issuer := range issuers { issuersByNameID[issuer.NameID()] = issuer @@ -280,6 +291,7 @@ func NewRegistrationAuthorityImpl( certCSRMismatch: certCSRMismatch, pauseCounter: pauseCounter, mustStapleRequestsCounter: mustStapleRequestsCounter, + newOrUpdatedContactCounter: newOrUpdatedContactCounter, } return ra } @@ -415,6 +427,12 @@ func (ra *RegistrationAuthorityImpl) NewRegistration(ctx context.Context, reques return nil, err } + // TODO(#7966): Remove once the rate of registrations with contacts has been + // determined. + for range request.Contact { + ra.newOrUpdatedContactCounter.With(prometheus.Labels{"new": "true"}).Inc() + } + ra.newRegCounter.Inc() return res, nil } @@ -1282,6 +1300,12 @@ func (ra *RegistrationAuthorityImpl) UpdateRegistrationContact(ctx context.Conte return nil, fmt.Errorf("failed to update registration contact: %w", err) } + // TODO(#7966): Remove once the rate of registrations with contacts has + // been determined. + for range req.Contacts { + ra.newOrUpdatedContactCounter.With(prometheus.Labels{"new": "false"}).Inc() + } + return update, nil }