From 55eaffcb4763ccf0513c5047c490dc286bb2e45b Mon Sep 17 00:00:00 2001 From: Matej Gera <38492574+matej-g@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:55:59 +0100 Subject: [PATCH] [target-allocator] Use `gin` in release mode and without default logger middleware (#1414) * Use gin in release mode and without default logger middleware Signed-off-by: Matej Gera * Add changelog Signed-off-by: Matej Gera --------- Signed-off-by: Matej Gera --- .chloggen/1414-adjust-gin-config.yaml | 16 ++++++++++++++++ cmd/otel-allocator/server/server.go | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .chloggen/1414-adjust-gin-config.yaml diff --git a/.chloggen/1414-adjust-gin-config.yaml b/.chloggen/1414-adjust-gin-config.yaml new file mode 100644 index 0000000000..95c455ab49 --- /dev/null +++ b/.chloggen/1414-adjust-gin-config.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) +component: "target allocator" + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Configure `gin` router to be used in release mode and do not use the default logging middleware which is noisy and not formatted properly." + +# One or more tracking issues related to the change +issues: [1352] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: \ No newline at end of file diff --git a/cmd/otel-allocator/server/server.go b/cmd/otel-allocator/server/server.go index c93cfe3514..fe769bb4ec 100644 --- a/cmd/otel-allocator/server/server.go +++ b/cmd/otel-allocator/server/server.go @@ -67,7 +67,9 @@ func NewServer(log logr.Logger, allocator allocation.Allocator, listenAddr *stri allocator: allocator, } - router := gin.Default() + gin.SetMode(gin.ReleaseMode) + router := gin.New() + router.Use(gin.Recovery()) router.UseRawPath = true router.UnescapePathValues = false router.Use(s.PrometheusMiddleware)