Skip to content

Commit

Permalink
Limit Prometheus metric warning log RPS (#6392)
Browse files Browse the repository at this point in the history
## What changed?
<!-- Describe what has changed in this PR -->
Add a metrics config to set logger RPS for prometheus. Default / 0 means
no limit.
  • Loading branch information
pdoerner authored Aug 9, 2024
1 parent ee64c4e commit 671a222
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ type (
// HTTP handler path "/metrics".
HandlerPath string `yaml:"handlerPath"`

// LoggerRPS sets the RPS of the logger provided to prometheus. Default of 0 means no limit.
LoggerRPS float64 `yaml:"loggerRPS"`

// Configs below are kept for backwards compatibility with previously exposed tally prometheus.Configuration.

// Deprecated. ListenNetwork if specified will be used instead of using tcp network.
Expand Down Expand Up @@ -297,6 +300,10 @@ func NewScope(logger log.Logger, c *Config) tally.Scope {
return nil
}

if c.Prometheus.LoggerRPS > 0 {
logger = log.NewThrottledLogger(logger, func() float64 { return c.Prometheus.LoggerRPS })
}

return newPrometheusScope(
logger,
convertPrometheusConfigToTally(&c.ClientConfig, c.Prometheus),
Expand Down

0 comments on commit 671a222

Please sign in to comment.