Add config to not log requests to metrics endpoint
This commit is contained in:
parent
d2fa727990
commit
52c2bd1060
@ -38,6 +38,9 @@ LogLevel = "INFO"
|
|||||||
# Enable access logging
|
# Enable access logging
|
||||||
# Default: true
|
# Default: true
|
||||||
AccessLogEnable = true
|
AccessLogEnable = true
|
||||||
|
# Disable logging of successful requests to metrics endpoint
|
||||||
|
# Default: false
|
||||||
|
AccessLogIgnoreMetrics = false
|
||||||
# Address and port to listen to
|
# Address and port to listen to
|
||||||
# Default: ":8080"
|
# Default: ":8080"
|
||||||
ListenAddr = ":8080"
|
ListenAddr = ":8080"
|
||||||
|
@ -37,6 +37,7 @@ type FrontendConfig struct {
|
|||||||
ListenAddr string `toml:"ListenAddr"`
|
ListenAddr string `toml:"ListenAddr"`
|
||||||
LogLevel string `toml:"LogLevel"`
|
LogLevel string `toml:"LogLevel"`
|
||||||
AccessLogEnable bool `toml:"AccessLogEnable"`
|
AccessLogEnable bool `toml:"AccessLogEnable"`
|
||||||
|
AccessLogIgnoreMetrics bool `toml:"AccessLogIgnoreMetrics"`
|
||||||
Autocert FrontendAutocertConfig `toml:"Autocert"`
|
Autocert FrontendAutocertConfig `toml:"Autocert"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ func FromReader(r io.Reader) (Config, error) {
|
|||||||
return c, fmt.Errorf("unable to parse config: %w", err)
|
return c, fmt.Errorf("unable to parse config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//c.readEnv()
|
// c.readEnv()
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Version = "v0.1.29"
|
Version = "v0.1.30"
|
||||||
Build string
|
Build string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,12 +17,10 @@ func (s *Server) LoggingMiddleware(next http.Handler) http.Handler {
|
|||||||
reqID := middleware.GetReqID(r.Context())
|
reqID := middleware.GetReqID(r.Context())
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
/*s.AccessLogger.Debugw(r.Method,
|
// If AccessLogIgnoreMetrics is true, do not log successful requests to metrics endpoint
|
||||||
"path", r.URL.Path,
|
if s.cfg.AccessLogIgnoreMetrics && r.URL.Path == "/metrics" && ww.Status() == http.StatusOK {
|
||||||
"request-headers", r.Header,
|
return
|
||||||
"response-headers", ww.Header(),
|
}
|
||||||
)
|
|
||||||
*/
|
|
||||||
s.AccessLogger.Infow(r.Method,
|
s.AccessLogger.Infow(r.Method,
|
||||||
"path", r.URL.Path,
|
"path", r.URL.Path,
|
||||||
"status", ww.Status(),
|
"status", ww.Status(),
|
||||||
|
Loading…
Reference in New Issue
Block a user