Skip to content

Commit

Permalink
Merge pull request #529 from bookingcom/grzkv/add_threshold_for_simpl…
Browse files Browse the repository at this point in the history
…e_reqs

Added a threshold parameter to differentiate simple vs complex requests.
  • Loading branch information
grzkv authored Sep 30, 2024
2 parents d43d1ef + 858979f commit fed0ea9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/app/carbonapi/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (app *App) renderHandler(w http.ResponseWriter, r *http.Request, lg *zap.Lo
defer func() {
//2xx response code is treated as success
if toLog.HttpCode/100 == 2 {
if toLog.TotalMetricCount < int64(app.config.ResolveGlobs) {
if toLog.TotalMetricCount < int64(app.config.SimpleRequestThreshold) {
app.ms.RenderDurationExpSimple.Observe(time.Since(t0).Seconds())
app.ms.RenderDurationLinSimple.Observe(time.Since(t0).Seconds())
} else {
Expand Down Expand Up @@ -901,7 +901,7 @@ func (app *App) findHandler(w http.ResponseWriter, r *http.Request, lg *zap.Logg
logLevel := zap.InfoLevel
defer func() {
if toLog.HttpCode/100 == 2 {
if toLog.TotalMetricCount < int64(app.config.ResolveGlobs) {
if toLog.TotalMetricCount < int64(app.config.SimpleRequestThreshold) {
app.ms.FindDurationLinSimple.Observe(time.Since(t0).Seconds())
} else {
app.ms.FindDurationLinComplex.Observe(time.Since(t0).Seconds())
Expand Down
4 changes: 4 additions & 0 deletions pkg/cfg/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func DefaultAPIConfig() API {
BucketsNum: 10,
BucketSize: 2,
},

SimpleRequestThreshold: 1000,
}

cfg.Listen = ":8081"
Expand Down Expand Up @@ -164,6 +166,8 @@ type API struct {
EmbedZipper bool `yaml:"embedZipper"`
// ZipperConfig represents the config for the embedded zipper.
ZipperConfig string `yaml:"zipperConfig"`

SimpleRequestThreshold int `yaml:"simpleRequestThreshold"`
}

// CacheConfig configs the cache
Expand Down

0 comments on commit fed0ea9

Please sign in to comment.