mirror of
https://github.com/caddyserver/caddy.git
synced 2025-11-02 06:36:29 +08:00
caddyhttp: Make metrics opt-in (#5042)
* caddyhttp: Make metrics opt-in Related to #4644 * Make configurable in Caddyfile
This commit is contained in:
@ -43,6 +43,7 @@ type serverOptions struct {
|
||||
Protocols []string
|
||||
StrictSNIHost *bool
|
||||
ShouldLogCredentials bool
|
||||
Metrics *caddyhttp.Metrics
|
||||
}
|
||||
|
||||
func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (any, error) {
|
||||
@ -175,6 +176,15 @@ func unmarshalCaddyfileServerOptions(d *caddyfile.Dispenser) (any, error) {
|
||||
}
|
||||
serverOpts.StrictSNIHost = &boolVal
|
||||
|
||||
case "metrics":
|
||||
if d.NextArg() {
|
||||
return nil, d.ArgErr()
|
||||
}
|
||||
if d.NextBlock(0) {
|
||||
return nil, d.ArgErr()
|
||||
}
|
||||
serverOpts.Metrics = new(caddyhttp.Metrics)
|
||||
|
||||
// TODO: DEPRECATED. (August 2022)
|
||||
case "protocol":
|
||||
caddy.Log().Named("caddyfile").Warn("DEPRECATED: protocol sub-option will be removed soon")
|
||||
@ -259,6 +269,7 @@ func applyServerOptions(
|
||||
server.MaxHeaderBytes = opts.MaxHeaderBytes
|
||||
server.Protocols = opts.Protocols
|
||||
server.StrictSNIHost = opts.StrictSNIHost
|
||||
server.Metrics = opts.Metrics
|
||||
if opts.ShouldLogCredentials {
|
||||
if server.Logs == nil {
|
||||
server.Logs = &caddyhttp.ServerLogConfig{}
|
||||
|
||||
Reference in New Issue
Block a user