Skip to content

Commit ecc796d

Browse files
authored
Add gauges for CRL size in bytes and num entries (#8720)
Fixes #8716
1 parent a177a48 commit ecc796d

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

crl/storer/storer.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ type crlStorer struct {
4242
s3Bucket string
4343
issuers map[issuance.NameID]*issuance.Certificate
4444
uploadCount *prometheus.CounterVec
45-
sizeHistogram *prometheus.HistogramVec
4645
latencyHistogram *prometheus.HistogramVec
4746
log blog.Logger
4847
clk clock.Clock
@@ -68,12 +67,6 @@ func New(
6867
Help: "A counter of the number of CRLs uploaded by crl-storer",
6968
}, []string{"issuer", "result"})
7069

71-
sizeHistogram := promauto.With(stats).NewHistogramVec(prometheus.HistogramOpts{
72-
Name: "crl_storer_sizes",
73-
Help: "A histogram of the sizes (in bytes) of CRLs uploaded by crl-storer",
74-
Buckets: []float64{0, 256, 1024, 4096, 16384, 65536},
75-
}, []string{"issuer"})
76-
7770
latencyHistogram := promauto.With(stats).NewHistogramVec(prometheus.HistogramOpts{
7871
Name: "crl_storer_upload_times",
7972
Help: "A histogram of the time (in seconds) it took crl-storer to upload CRLs",
@@ -85,7 +78,6 @@ func New(
8578
s3Client: s3Client,
8679
s3Bucket: s3Bucket,
8780
uploadCount: uploadCount,
88-
sizeHistogram: sizeHistogram,
8981
latencyHistogram: latencyHistogram,
9082
log: log,
9183
clk: clk,
@@ -149,8 +141,6 @@ func (cs *crlStorer) UploadCRL(stream grpc.ClientStreamingServer[cspb.UploadCRLR
149141

150142
crlId := crl.Id(issuer.NameID(), int(shardIdx), crlNumber)
151143

152-
cs.sizeHistogram.WithLabelValues(issuer.Subject.CommonName).Observe(float64(len(crlBytes)))
153-
154144
crl, err := x509.ParseRevocationList(crlBytes)
155145
if err != nil {
156146
return fmt.Errorf("parsing CRL for %s: %w", crlId, err)

crl/updater/updater.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/sha256"
66
"fmt"
77
"io"
8+
"strconv"
89
"time"
910

1011
"github.com/jmhodges/clock"
@@ -39,8 +40,10 @@ type crlUpdater struct {
3940
ca capb.CRLGeneratorClient
4041
cs cspb.CRLStorerClient
4142

42-
tickHistogram *prometheus.HistogramVec
43-
updatedCounter *prometheus.CounterVec
43+
tickHistogram *prometheus.HistogramVec
44+
updatedCounter *prometheus.CounterVec
45+
sizeBytesGauge *prometheus.GaugeVec
46+
sizeEntriesGauge *prometheus.GaugeVec
4447

4548
log blog.Logger
4649
clk clock.Clock
@@ -104,6 +107,16 @@ func NewUpdater(
104107
Help: "A counter of CRL generation calls labeled by result",
105108
}, []string{"issuer", "result"})
106109

110+
sizeBytesGauge := promauto.With(stats).NewGaugeVec(prometheus.GaugeOpts{
111+
Name: "crl_updater_crl_size_bytes",
112+
Help: "The size in bytes of each CRL, labeled by issuer and shard",
113+
}, []string{"issuer", "shard"})
114+
115+
sizeEntriesGauge := promauto.With(stats).NewGaugeVec(prometheus.GaugeOpts{
116+
Name: "crl_updater_crl_size_entries",
117+
Help: "The number of entries in each CRL, labeled by issuer and shard",
118+
}, []string{"issuer", "shard"})
119+
107120
return &crlUpdater{
108121
issuersByNameID,
109122
numShards,
@@ -120,6 +133,8 @@ func NewUpdater(
120133
cs,
121134
tickHistogram,
122135
updatedCounter,
136+
sizeBytesGauge,
137+
sizeEntriesGauge,
123138
log,
124139
clk,
125140
}, nil
@@ -324,6 +339,8 @@ func (cu *crlUpdater) updateShard(ctx context.Context, atTime time.Time, issuerN
324339
cu.log.Infof(
325340
"Generated CRL shard: id=[%s] size=[%d] hash=[%x]",
326341
crlID, crlLen, crlHash.Sum(nil))
342+
cu.sizeBytesGauge.WithLabelValues(cu.issuers[issuerNameID].Subject.CommonName, strconv.Itoa(shardIdx)).Set(float64(crlLen))
343+
cu.sizeEntriesGauge.WithLabelValues(cu.issuers[issuerNameID].Subject.CommonName, strconv.Itoa(shardIdx)).Set(float64(len(crlEntries)))
327344

328345
return nil
329346
}

0 commit comments

Comments
 (0)