Skip to content

Commit c22914c

Browse files
authored
fix: Don't log health checks in a cloud environment (#14)
* fix: Don't log health checks in a cloud environment * Reference the action name instead of the path
1 parent 5915919 commit c22914c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

internal/server/logger.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@ func Logger(inner http.Handler, name string) http.Handler {
3737
inner.ServeHTTP(lrw, r)
3838

3939
if config.GetConfig().StructuredLogging {
40-
http := log.ECSHTTP{
41-
Request: log.ECSRequest{
42-
Method: r.Method,
43-
},
44-
Response: log.ECSResponse{
45-
StatusCode: lrw.statusCode,
46-
},
47-
}
48-
url := log.ECSURL{Original: r.RequestURI}
49-
event := log.ECSEvent{Action: name, Duration: time.Since(start)}
40+
// Don't log health checks in a cloud environment - name is defined in the schema
41+
if name != "ReadyCheck" {
42+
http := log.ECSHTTP{
43+
Request: log.ECSRequest{
44+
Method: r.Method,
45+
},
46+
Response: log.ECSResponse{
47+
StatusCode: lrw.statusCode,
48+
},
49+
}
50+
url := log.ECSURL{Original: r.RequestURI}
51+
event := log.ECSEvent{Action: name, Duration: time.Since(start)}
5052

51-
zap.S().Infow("HTTP Request", zap.Any("http", http), zap.Any("url", url), zap.Any("event", event))
53+
zap.S().Infow("HTTP Request", zap.Any("http", http), zap.Any("url", url), zap.Any("event", event))
54+
}
5255
} else {
5356
zap.S().Infow("HTTP Request",
5457
"method", r.Method,

0 commit comments

Comments
 (0)