@@ -36,8 +36,14 @@ func (m *measuringRegistryRoundTripper) RoundTrip(req *http.Request) (*http.Resp
3636
3737 if strings .Contains (req .URL .Path , "/manifests/" ) {
3838 m .metrics .ManifestHist .Observe (dt .Seconds ())
39+ if err != nil {
40+ m .metrics .ReqFailedCounter .WithLabelValues ("manifest" ).Inc ()
41+ }
3942 } else if strings .Contains (req .URL .Path , "/blobs/" ) {
4043 m .metrics .BlobCounter .Inc ()
44+ if err != nil {
45+ m .metrics .ReqFailedCounter .WithLabelValues ("blob" ).Inc ()
46+ }
4147 }
4248
4349 return resp , err
@@ -46,6 +52,7 @@ func (m *measuringRegistryRoundTripper) RoundTrip(req *http.Request) (*http.Resp
4652// Metrics combine custom metrics exported by registry facade
4753type metrics struct {
4854 ManifestHist prometheus.Histogram
55+ ReqFailedCounter * prometheus.CounterVec
4956 BlobCounter prometheus.Counter
5057 BlobDownloadSpeedHist prometheus.Histogram
5158}
@@ -61,6 +68,17 @@ func newMetrics(reg prometheus.Registerer, upstream bool) (*metrics, error) {
6168 return nil , err
6269 }
6370
71+ reqFailedCounter := prometheus .NewCounterVec (
72+ prometheus.CounterOpts {
73+ Name : "req_failed_total" ,
74+ Help : "number of requests that failed" ,
75+ }, []string {"type" },
76+ )
77+ err = reg .Register (reqFailedCounter )
78+ if err != nil {
79+ return nil , err
80+ }
81+
6482 blobCounter := prometheus .NewCounter (prometheus.CounterOpts {
6583 Name : "blob_req_total" ,
6684 Help : "number of blob requests made to the downstream registry" ,
@@ -84,6 +102,7 @@ func newMetrics(reg prometheus.Registerer, upstream bool) (*metrics, error) {
84102
85103 return & metrics {
86104 ManifestHist : manifestHist ,
105+ ReqFailedCounter : reqFailedCounter ,
87106 BlobCounter : blobCounter ,
88107 BlobDownloadSpeedHist : blobDownloadSpeedHist ,
89108 }, nil
0 commit comments