20 lines
560 B
Go
20 lines
560 B
Go
package synthetic
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
const EnabledEnv = "BELL_SYNTHETIC_EVENTS_ENABLED"
|
|
|
|
// Enabled requires both a non-production runtime and an explicit opt-in.
|
|
func Enabled(mode string, getenv func(string) string) bool {
|
|
if strings.EqualFold(strings.TrimSpace(mode), "prod") || strings.EqualFold(strings.TrimSpace(mode), "production") {
|
|
return false
|
|
}
|
|
value := strings.ToLower(strings.TrimSpace(getenv(EnabledEnv)))
|
|
return value == "true" || value == "1"
|
|
}
|
|
|
|
func EnabledFromEnvironment(mode string) bool { return Enabled(mode, os.Getenv) }
|