From ec943b23028d7360565a48f2148556fbf874ada5 Mon Sep 17 00:00:00 2001 From: zhuojie Date: Fri, 8 Mar 2019 18:03:43 -0800 Subject: [PATCH] Add EvalDebugEnabled env variable --- pkg/config/env.go | 5 +++++ pkg/handler/eval.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/config/env.go b/pkg/config/env.go index 8c0feb36..dc543e24 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -30,6 +30,11 @@ var Config = struct { EvalCacheRefreshTimeout time.Duration `env:"FLAGR_EVALCACHE_REFRESHTIMEOUT" envDefault:"59s"` // EvalCacheRefreshInterval - time interval of getting the flags data from DB into the in-memory evaluation cache EvalCacheRefreshInterval time.Duration `env:"FLAGR_EVALCACHE_REFRESHINTERVAL" envDefault:"3s"` + // EvalEnableDebug - controls if we want to return evaluation debugging information back to the api requests + // Note that this is a global switch: + // if it's disabled, no evaluation debug info will be returned. + // if it's enabled, it respects evaluation request's enableDebug field + EvalDebugEnabled bool `env:"FLAGR_EVAL_DEBUG_ENABLED" envDefault:"true"` // DBDriver - Flagr supports sqlite3, mysql, postgres DBDriver string `env:"FLAGR_DB_DBDRIVER" envDefault:"sqlite3"` diff --git a/pkg/handler/eval.go b/pkg/handler/eval.go index cfe2d8b4..85ce805a 100644 --- a/pkg/handler/eval.go +++ b/pkg/handler/eval.go @@ -144,7 +144,7 @@ var evalFlag = func(evalContext models.EvalContext) *models.EvalResult { for _, segment := range f.Segments { sID = util.Int64Ptr(int64(segment.ID)) variantID, log, evalNextSegment := evalSegment(f.ID, evalContext, segment) - if evalContext.EnableDebug { + if config.Config.EvalDebugEnabled && evalContext.EnableDebug { logs = append(logs, log) } if variantID != nil {