func()

in pkg/controller/sync/sync.go [164:199]


func (s impl) reportManagedCertificatesAttached(ctx context.Context, managedCertificates []types.Id) error {
	for _, id := range managedCertificates {
		entry, err := s.state.Get(id)
		if err != nil {
			return err
		}

		if entry.ExcludedFromSLO {
			klog.Infof("Skipping reporting SslCertificate binding metric: %s is marked as excluded from SLO calculations.", id.String())
			continue
		}

		if entry.SslCertificateBindingReported {
			klog.Infof("Skipping reporting SslCertificate binding metric: already reported for %s.", id.String())
			continue
		}

		mcrt, err := s.managedCertificate.Get(id)
		if err != nil {
			return err
		}

		creationTime, err := time.Parse(time.RFC3339, mcrt.CreationTimestamp.Format(time.RFC3339))
		if err != nil {
			return err
		}

		s.metrics.ObserveSslCertificateBindingLatency(creationTime)

		if err := s.state.SetSslCertificateBindingReported(ctx, id); err != nil {
			return err
		}
	}

	return nil
}