Skip to content

Commit 89bee48

Browse files
committed
revproxy: add metrics for uncached and volatile objects
1 parent f07ff4e commit 89bee48

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

revproxy/revproxy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ type Server struct {
105105
reqFaultMiss expvar.Int // miss in remote (S3) cache
106106
reqForward expvar.Int // request forwarded directly to upstream
107107
rspSave expvar.Int // successful response saved in local cache
108+
rspSaveMem expvar.Int // response saved in memory cache
108109
rspSaveError expvar.Int // error saving to local cache
109110
rspSaveBytes expvar.Int // bytes written to local cache
110111
rspPush expvar.Int // successful response saved in S3
111112
rspPushError expvar.Int // error saving to S3
112113
rspPushBytes expvar.Int // bytes written to S3
114+
rspNotCached expvar.Int // response not cached anywhere
113115
}
114116

115117
func (s *Server) init() {
@@ -132,11 +134,13 @@ func (s *Server) Metrics() *expvar.Map {
132134
m.Set("req_fault_miss", &s.reqFaultMiss)
133135
m.Set("req_forward", &s.reqForward)
134136
m.Set("rsp_save", &s.rspSave)
137+
m.Set("rsp_save_memory", &s.rspSaveMem)
135138
m.Set("rsp_save_error", &s.rspSaveError)
136139
m.Set("rsp_save_bytes", &s.rspSaveBytes)
137140
m.Set("rsp_push", &s.rspPush)
138141
m.Set("rsp_push_error", &s.rspPushError)
139142
m.Set("rsp_push_bytes", &s.rspPushBytes)
143+
m.Set("rsp_not_cached", &s.rspNotCached)
140144
return m
141145
}
142146

@@ -197,6 +201,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
197201
if !isVolatile && !s.canCacheResponse(rsp) {
198202
// A response we cannot cache at all.
199203
setXCacheInfo(rsp.Header, "fetch, uncached", "")
204+
s.rspNotCached.Add(1)
200205
return nil
201206
}
202207

@@ -212,6 +217,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
212217
updateCache = func() {
213218
body := buf.Bytes()
214219
s.cacheStoreMemory(hash, maxAge, rsp.Header, body)
220+
s.rspSaveMem.Add(1)
215221

216222
// N.B. Don't persist on disk or in S3.
217223
}

0 commit comments

Comments
 (0)