Commit e6333fb2 authored by Manoj M J's avatar Manoj M J

Measure image scaler duration for cached images

With this change, we measure durations in Prometheus
(in `imageResizeDurations`) whenever the requested image has not been modified and hence the cached version can be used by the client.

In this case, the image resizer process is not invoked, but
the client gets to see the image anyway.

As apdex is a measure of user satisfaction, it should not matter “where does the image come from?”, rather it should only care about “how soon is the image served”, which is why we have now decided toinclude the measurement of “cached versions” delivery in this apdex.

Changelog: changed
parent 055d8bce
......@@ -186,12 +186,15 @@ func (r *Resizer) Inject(w http.ResponseWriter, req *http.Request, paramsData st
}
defer imageFile.reader.Close()
widthLabelVal := strconv.Itoa(int(params.Width))
outcome.originalFileSize = imageFile.contentLength
setLastModified(w, imageFile.lastModified)
// If the original file has not changed, then any cached resized versions have not changed either.
if checkNotModified(req, imageFile.lastModified) {
writeNotModified(w)
imageResizeDurations.WithLabelValues(params.ContentType, widthLabelVal).Observe(time.Since(start).Seconds())
outcome.ok(statusClientCache)
return
}
......@@ -221,7 +224,6 @@ func (r *Resizer) Inject(w http.ResponseWriter, req *http.Request, paramsData st
return
}
widthLabelVal := strconv.Itoa(int(params.Width))
imageResizeDurations.WithLabelValues(params.ContentType, widthLabelVal).Observe(time.Since(start).Seconds())
outcome.ok(statusSuccess)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment