-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: standardize env for query service #5670
Conversation
Welcome to the SigNoz community! Thank you for your first pull request and making this project better. 🤗 |
|
@shivanshuraj1333 Can you please review it. |
This is not what I intended, package config
import (
"os"
)
type Config struct {
SignozJwtSecret string
StorageType string
ClickHouseUrl string
ClickHouseOptimizeReadInOrderRegex string
ClickHouseMaxExecutionTimeLeaf string
ClickHouseTimeoutBeforeCheckingExecutionSpeed string
ClickHouseMaxBytesToRead string
SmtpEnabled string
DeploymentType string
SmtpHost string
SmtpPort string
SmtpUsername string
SmtpPassword string
SmtpFrom string
}
var AppConfig Config
func LoadConfig() {
AppConfig = Config{
SignozJwtSecret: os.Getenv("SIGNOZ_JWT_SECRET"),
StorageType: os.Getenv("STORAGE"),
ClickHouseUrl: os.Getenv("CLICKHOUSE_URL"),
ClickHouseOptimizeReadInOrderRegex: os.Getenv("CLICKHOUSE_OPTIMIZE_READ_IN_ORDER_REGEX"),
ClickHouseMaxExecutionTimeLeaf: os.Getenv("CLICKHOUSE_MAX_EXECUTION_TIME_LEAF"),
ClickHouseTimeoutBeforeCheckingExecutionSpeed: os.Getenv("CLICKHOUSE_TIMEOUT_BEFORE_CHECKING_EXECUTION_SPEED"),
ClickHouseMaxBytesToRead: os.Getenv("CLICKHOUSE_MAX_BYTES_TO_READ"),
SmtpEnabled: os.Getenv("SMTP_ENABLED"),
DeploymentType: os.Getenv("DEPLOYMENT_TYPE"),
SmtpHost: os.Getenv("SMTP_HOST"),
SmtpPort: os.Getenv("SMTP_PORT"),
SmtpUsername: os.Getenv("SMTP_USERNAME"),
SmtpPassword: os.Getenv("SMTP_PASSWORD"),
SmtpFrom: os.Getenv("SMTP_FROM"),
}
} and use it like below |
Ok, make sense.
|
No, |
} | ||
if len(queryServiceConfig.AppConfig.ClickHouseMaxBytesToRead) == 0 { | ||
zap.L().Warn("No ClickHouseMaxBytesToRead env is specified.") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of having an helper function which will have this check inside it and log it if env variables not found so that we don't need to repeat the same check
func EnvVariableChecker(env ...string) {
for _, val := range env {
if len(val) == 0 {
zap.L().Warn(fmt.Sprintf("No %s env is specified.", val))
}
}
}
but in this case the %s will be empty as there will be no value. So added the check for all the env variables.
Shouldn't this check and alert all errors on load? I don't think the system is much use without a |
Hi @slayer321, As part of the config being created, we are also going to validate and fail fast. That should take care of @Aeolun's point! |
Summary
Standardize ENV variable for query service
Related Issues / PR's
fixes #5266