Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/trace/api/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type reducedObfuscationConfig struct {
Mongo bool `json:"mongo"`
SQLExecPlan bool `json:"sql_exec_plan"`
SQLExecPlanNormalize bool `json:"sql_exec_plan_normalize"`
SQLObfuscationMode obfuscate.ObfuscationMode `json:"sql_obfuscation_mode"`
HTTP obfuscate.HTTPConfig `json:"http"`
RemoveStackTraces bool `json:"remove_stack_traces"`
Redis obfuscate.RedisConfig `json:"redis"`
Expand Down Expand Up @@ -87,6 +88,7 @@ func (r *HTTPReceiver) makeInfoHandler() (hash string, handler http.HandlerFunc)
oconf.Mongo = o.Mongo.Enabled
oconf.SQLExecPlan = o.SQLExecPlan.Enabled
oconf.SQLExecPlanNormalize = o.SQLExecPlanNormalize.Enabled
oconf.SQLObfuscationMode = r.conf.EffectiveSQLObfuscationMode()
oconf.HTTP = o.HTTP
oconf.RemoveStackTraces = o.RemoveStackTraces
oconf.Redis = o.Redis
Expand Down
1 change: 1 addition & 0 deletions pkg/trace/api/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func TestInfoHandler(t *testing.T) {
"mongo": nil,
"sql_exec_plan": nil,
"sql_exec_plan_normalize": nil,
"sql_obfuscation_mode": nil,
"http": map[string]any{
"remove_query_string": nil,
"remove_path_digits": nil,
Expand Down
9 changes: 8 additions & 1 deletion pkg/trace/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ func obfuscationMode(conf *AgentConfig, sqllexerEnabled bool) obfuscate.Obfuscat
return ""
}

// EffectiveSQLObfuscationMode returns the SQL obfuscation mode the agent
// actually uses at runtime. When SQLObfuscationMode is not explicitly set,
// the mode is derived from feature flags (e.g. sqllexer → obfuscate_only).
func (c *AgentConfig) EffectiveSQLObfuscationMode() obfuscate.ObfuscationMode {
return obfuscationMode(c, c.HasFeature("sqllexer"))
}

// Export returns an obfuscate.Config matching o.
func (o *ObfuscationConfig) Export(conf *AgentConfig) obfuscate.Config {
return obfuscate.Config{
Expand All @@ -160,7 +167,7 @@ func (o *ObfuscationConfig) Export(conf *AgentConfig) obfuscate.Config {
ReplaceDigits: conf.HasFeature("quantize_sql_tables") || conf.HasFeature("replace_sql_digits"),
KeepSQLAlias: conf.HasFeature("keep_sql_alias"),
DollarQuotedFunc: conf.HasFeature("dollar_quoted_func"),
ObfuscationMode: obfuscationMode(conf, conf.HasFeature("sqllexer")),
ObfuscationMode: conf.EffectiveSQLObfuscationMode(),
},
ES: o.ES,
OpenSearch: o.OpenSearch,
Expand Down
19 changes: 19 additions & 0 deletions pkg/trace/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ func TestSQLObfuscationMode(t *testing.T) {
})
}

func TestEffectiveSQLObfuscationMode(t *testing.T) {
t.Run("sqllexer_enabled_no_explicit_mode", func(t *testing.T) {
cfg := New()
cfg.Features = map[string]struct{}{"sqllexer": {}}
// SQLObfuscationMode is empty; effective mode must be obfuscate_only
assert.Equal(t, obfuscate.ObfuscateOnly, cfg.EffectiveSQLObfuscationMode())
})
t.Run("explicit_mode_takes_precedence", func(t *testing.T) {
cfg := New()
cfg.Features = map[string]struct{}{"sqllexer": {}}
cfg.SQLObfuscationMode = string(obfuscate.ObfuscateAndNormalize)
assert.Equal(t, obfuscate.ObfuscateAndNormalize, cfg.EffectiveSQLObfuscationMode())
})
t.Run("no_sqllexer_no_explicit_mode", func(t *testing.T) {
cfg := New()
assert.Equal(t, obfuscate.ObfuscationMode(""), cfg.EffectiveSQLObfuscationMode())
})
}

func TestInECSManagedInstancesSidecar(t *testing.T) {
t.Setenv("DD_ECS_DEPLOYMENT_MODE", "sidecar")
t.Setenv("AWS_EXECUTION_ENV", "AWS_ECS_MANAGED_INSTANCES")
Expand Down
Loading