Commit a8a34f88 authored by Matthias Käppler's avatar Matthias Käppler Committed by Nick Thomas

Add the success-client-cache status for image scaler

Since we weren't counting cached responses as successes, in Prometheus there were showing up as `unknown`, which contributes to the overall error budget.

We need to follow up with a runbook change that also counts cached responses as successes.
parent b4e50d0f
---
title: 'Image scaler: add success-client-cache status label'
merge_request: 656
author:
type: fixed
......@@ -51,10 +51,11 @@ type imageFile struct {
}
const (
statusSuccess = "success" // a rescaled image was served
statusScalingFailure = "scaling-failed" // scaling failed but the original image was served
statusRequestFailure = "request-failed" // no image was served
statusUnknown = "unknown" // indicates an unhandled status case
statusSuccess = "success" // a rescaled image was served
statusClientCache = "success-client-cache" // scaling was skipped because client cache was fresh
statusScalingFailure = "scaling-failed" // scaling failed but the original image was served
statusRequestFailure = "request-failed" // no image was served
statusUnknown = "unknown" // indicates an unhandled status case
)
var envInjector = tracing.NewEnvInjector()
......@@ -197,6 +198,7 @@ func (r *Resizer) Inject(w http.ResponseWriter, req *http.Request, paramsData st
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) {
status = statusClientCache
logger.WithFields(*logFields(0)).Printf("ImageResizer: Use cached image")
writeNotModified(w)
return
......
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