@@ -36,8 +36,14 @@ func (m *measuringRegistryRoundTripper) RoundTrip(req *http.Request) (*http.Resp
36
36
37
37
if strings .Contains (req .URL .Path , "/manifests/" ) {
38
38
m .metrics .ManifestHist .Observe (dt .Seconds ())
39
+ if err != nil {
40
+ m .metrics .ReqFailedCounter .WithLabelValues ("manifest" ).Inc ()
41
+ }
39
42
} else if strings .Contains (req .URL .Path , "/blobs/" ) {
40
43
m .metrics .BlobCounter .Inc ()
44
+ if err != nil {
45
+ m .metrics .ReqFailedCounter .WithLabelValues ("blob" ).Inc ()
46
+ }
41
47
}
42
48
43
49
return resp , err
@@ -46,6 +52,7 @@ func (m *measuringRegistryRoundTripper) RoundTrip(req *http.Request) (*http.Resp
46
52
// Metrics combine custom metrics exported by registry facade
47
53
type metrics struct {
48
54
ManifestHist prometheus.Histogram
55
+ ReqFailedCounter * prometheus.CounterVec
49
56
BlobCounter prometheus.Counter
50
57
BlobDownloadSpeedHist prometheus.Histogram
51
58
}
@@ -61,6 +68,17 @@ func newMetrics(reg prometheus.Registerer, upstream bool) (*metrics, error) {
61
68
return nil , err
62
69
}
63
70
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
+
64
82
blobCounter := prometheus .NewCounter (prometheus.CounterOpts {
65
83
Name : "blob_req_total" ,
66
84
Help : "number of blob requests made to the downstream registry" ,
@@ -84,6 +102,7 @@ func newMetrics(reg prometheus.Registerer, upstream bool) (*metrics, error) {
84
102
85
103
return & metrics {
86
104
ManifestHist : manifestHist ,
105
+ ReqFailedCounter : reqFailedCounter ,
87
106
BlobCounter : blobCounter ,
88
107
BlobDownloadSpeedHist : blobDownloadSpeedHist ,
89
108
}, nil
0 commit comments