Skip to content

Commit

Permalink
bind default value to apm_config.obfuscation.*
Browse files Browse the repository at this point in the history
  • Loading branch information
keisku committed Dec 18, 2024
1 parent 26052f9 commit 136f97b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
12 changes: 6 additions & 6 deletions pkg/config/config_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1235,28 +1235,28 @@ api_key:
# remove_stack_traces: false
#
# sql_exec_plan:
## @param DD_APM_SQL_EXEC_PLAN_ENABLED - boolean - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_ENABLED - boolean - optional
## Enables obfuscation rules for JSON query execution plans. Disabled by default.
# enabled: false
## @param DD_APM_SQL_EXEC_PLAN_KEEP_VALUES - object - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_KEEP_VALUES - object - optional
## List of keys that should not be obfuscated.
# keep_values:
# - id1
## @param DD_APM_SQL_EXEC_PLAN_OBFUSCATE_SQL_VALUES - boolean - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_OBFUSCATE_SQL_VALUES - boolean - optional
## The set of keys for which their values will be passed through SQL obfuscation
# obfuscate_sql_values:
# - val1
#
# sql_exec_plan_normalize:
## @param DD_APM_SQL_EXEC_PLAN_NORMALIZE_ENABLED - boolean - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_ENABLED - boolean - optional
## Enables obfuscation rules for JSON query execution plans, including cost and row estimates.
## Produces a normalized execution plan. Disabled by default.
# enabled: false
## @param DD_APM_SQL_EXEC_PLAN_NORMALIZE_KEEP_VALUES - object - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_KEEP_VALUES - object - optional
## List of keys that should not be obfuscated.
# keep_values:
# - id1
## @param DD_APM_SQL_EXEC_PLAN_NORMALIZE_OBFUSCATE_SQL_VALUES - boolean - optional
## @param DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_OBFUSCATE_SQL_VALUES - boolean - optional
## The set of keys for which their values will be passed through SQL obfuscation
# obfuscate_sql_values:
# - val1
Expand Down
58 changes: 32 additions & 26 deletions pkg/config/setup/apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,35 @@ import (
const Traces DataType = "traces"

func setupAPM(config pkgconfigmodel.Setup) {
config.BindEnv("apm_config.obfuscation.elasticsearch.enabled", "DD_APM_OBFUSCATION_ELASTICSEARCH_ENABLED")
config.BindEnv("apm_config.obfuscation.elasticsearch.keep_values", "DD_APM_OBFUSCATION_ELASTICSEARCH_KEEP_VALUES")
config.BindEnv("apm_config.obfuscation.elasticsearch.obfuscate_sql_values", "DD_APM_OBFUSCATION_ELASTICSEARCH_OBFUSCATE_SQL_VALUES")
config.BindEnv("apm_config.obfuscation.opensearch.enabled", "DD_APM_OBFUSCATION_OPENSEARCH_ENABLED")
config.BindEnv("apm_config.obfuscation.opensearch.keep_values", "DD_APM_OBFUSCATION_OPENSEARCH_KEEP_VALUES")
config.BindEnv("apm_config.obfuscation.opensearch.obfuscate_sql_values", "DD_APM_OBFUSCATION_OPENSEARCH_OBFUSCATE_SQL_VALUES")
config.BindEnv("apm_config.obfuscation.mongodb.enabled", "DD_APM_OBFUSCATION_MONGODB_ENABLED")
config.BindEnv("apm_config.obfuscation.mongodb.keep_values", "DD_APM_OBFUSCATION_MONGODB_KEEP_VALUES")
config.BindEnv("apm_config.obfuscation.mongodb.obfuscate_sql_values", "DD_APM_OBFUSCATION_MONGODB_OBFUSCATE_SQL_VALUES")
config.BindEnv("apm_config.obfuscation.sql_exec_plan.enabled", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_ENABLED")
config.BindEnv("apm_config.obfuscation.sql_exec_plan.keep_values", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_KEEP_VALUES")
config.BindEnv("apm_config.obfuscation.sql_exec_plan.obfuscate_sql_values", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_OBFUSCATE_SQL_VALUES")
config.BindEnv("apm_config.obfuscation.sql_exec_plan_normalize.enabled", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_ENABLED")
config.BindEnv("apm_config.obfuscation.sql_exec_plan_normalize.keep_values", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_KEEP_VALUES")
config.BindEnv("apm_config.obfuscation.sql_exec_plan_normalize.obfuscate_sql_values", "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_OBFUSCATE_SQL_VALUES")
config.BindEnv("apm_config.obfuscation.http.remove_query_string", "DD_APM_OBFUSCATION_HTTP_REMOVE_QUERY_STRING")
config.BindEnv("apm_config.obfuscation.http.remove_paths_with_digits", "DD_APM_OBFUSCATION_HTTP_REMOVE_PATHS_WITH_DIGITS")
config.BindEnv("apm_config.obfuscation.remove_stack_traces", "DD_APM_OBFUSCATION_REMOVE_STACK_TRACES")
config.BindEnv("apm_config.obfuscation.redis.enabled", "DD_APM_OBFUSCATION_REDIS_ENABLED")
config.BindEnv("apm_config.obfuscation.redis.remove_all_args", "DD_APM_OBFUSCATION_REDIS_REMOVE_ALL_ARGS")
config.BindEnv("apm_config.obfuscation.memcached.enabled", "DD_APM_OBFUSCATION_MEMCACHED_ENABLED")
config.BindEnv("apm_config.obfuscation.memcached.keep_command", "DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND")
config.BindEnv("apm_config.obfuscation.cache.enabled", "DD_APM_OBFUSCATION_CACHE_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.elasticsearch.enabled", true, "DD_APM_OBFUSCATION_ELASTICSEARCH_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.elasticsearch.keep_values", []string{}, "DD_APM_OBFUSCATION_ELASTICSEARCH_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.elasticsearch.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_ELASTICSEARCH_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.opensearch.enabled", true, "DD_APM_OBFUSCATION_OPENSEARCH_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.opensearch.keep_values", []string{}, "DD_APM_OBFUSCATION_OPENSEARCH_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.opensearch.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_OPENSEARCH_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.mongodb.enabled", true, "DD_APM_OBFUSCATION_MONGODB_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.mongodb.keep_values", []string{}, "DD_APM_OBFUSCATION_MONGODB_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.mongodb.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_MONGODB_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.enabled", false, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.keep_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.enabled", false, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.keep_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.http.remove_query_string", false, "DD_APM_OBFUSCATION_HTTP_REMOVE_QUERY_STRING")
config.BindEnvAndSetDefault("apm_config.obfuscation.http.remove_paths_with_digits", false, "DD_APM_OBFUSCATION_HTTP_REMOVE_PATHS_WITH_DIGITS")
config.BindEnvAndSetDefault("apm_config.obfuscation.remove_stack_traces", false, "DD_APM_OBFUSCATION_REMOVE_STACK_TRACES")
config.BindEnvAndSetDefault("apm_config.obfuscation.redis.enabled", true, "DD_APM_OBFUSCATION_REDIS_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.redis.remove_all_args", false, "DD_APM_OBFUSCATION_REDIS_REMOVE_ALL_ARGS")
config.BindEnvAndSetDefault("apm_config.obfuscation.memcached.enabled", true, "DD_APM_OBFUSCATION_MEMCACHED_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.memcached.keep_command", false, "DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.enabled", true, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.keep_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.enabled", true, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.keep_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.sql_exec_plan_normalize.obfuscate_sql_values", []string{}, "DD_APM_OBFUSCATION_SQL_EXEC_PLAN_NORMALIZE_OBFUSCATE_SQL_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.cache.enabled", true, "DD_APM_OBFUSCATION_CACHE_ENABLED")
config.SetKnown("apm_config.filter_tags.require")
config.SetKnown("apm_config.filter_tags.reject")
config.SetKnown("apm_config.filter_tags_regex.require")
Expand Down Expand Up @@ -151,9 +157,9 @@ func setupAPM(config pkgconfigmodel.Setup) {
config.BindEnv("apm_config.install_id", "DD_INSTRUMENTATION_INSTALL_ID")
config.BindEnv("apm_config.install_type", "DD_INSTRUMENTATION_INSTALL_TYPE")
config.BindEnv("apm_config.install_time", "DD_INSTRUMENTATION_INSTALL_TIME")
config.BindEnv("apm_config.obfuscation.credit_cards.enabled", "DD_APM_OBFUSCATION_CREDIT_CARDS_ENABLED")
config.BindEnv("apm_config.obfuscation.credit_cards.luhn", "DD_APM_OBFUSCATION_CREDIT_CARDS_LUHN")
config.BindEnv("apm_config.obfuscation.credit_cards.keep_values", "DD_APM_OBFUSCATION_CREDIT_CARDS_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.obfuscation.credit_cards.enabled", true, "DD_APM_OBFUSCATION_CREDIT_CARDS_ENABLED")
config.BindEnvAndSetDefault("apm_config.obfuscation.credit_cards.luhn", false, "DD_APM_OBFUSCATION_CREDIT_CARDS_LUHN")
config.BindEnvAndSetDefault("apm_config.obfuscation.credit_cards.keep_values", []string{}, "DD_APM_OBFUSCATION_CREDIT_CARDS_KEEP_VALUES")
config.BindEnvAndSetDefault("apm_config.debug.port", 5012, "DD_APM_DEBUG_PORT")
config.BindEnv("apm_config.features", "DD_APM_FEATURES")
config.ParseEnvAsStringSlice("apm_config.features", func(s string) []string {
Expand Down

0 comments on commit 136f97b

Please sign in to comment.