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