浏览代码

prometheus: enable gzip for /metrics endpoint

closes #9464
bergquist 8 年之前
父节点
当前提交
139f077453
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 2 3
      pkg/api/http_server.go
  2. 4 0
      pkg/middleware/util.go

+ 2 - 3
pkg/api/http_server.go

@@ -188,9 +188,8 @@ func (hs *HttpServer) metricsEndpoint(ctx *macaron.Context) {
 		return
 		return
 	}
 	}
 
 
-	promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
-		DisableCompression: true,
-	}).ServeHTTP(ctx.Resp, ctx.Req.Request)
+	promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).
+		ServeHTTP(ctx.Resp, ctx.Req.Request)
 }
 }
 
 
 func (hs *HttpServer) healthHandler(ctx *macaron.Context) {
 func (hs *HttpServer) healthHandler(ctx *macaron.Context) {

+ 4 - 0
pkg/middleware/util.go

@@ -21,6 +21,10 @@ func Gziper() macaron.Handler {
 			return
 			return
 		}
 		}
 
 
+		if strings.HasPrefix(requestPath, "/metrics") {
+			return
+		}
+
 		ctx.Invoke(macaronGziper)
 		ctx.Invoke(macaronGziper)
 	}
 	}
 }
 }