Skip to content

Obfuscation: no way to produce the Agent's sql.tables tag (table_names) #2922

Open

Description

@lucastemb

Is your feature request related to a problem? Please describe.
The Agent can attach the tables a SQL query touches as a sql.tables span tag. libdd-trace-obfuscation has no way to produce it, so a consumer replacing the Agent's obfuscation with libdatadog's loses the tag for users who turned the feature on.

Agent behavior

  • SQLConfig.TableNames is set from the table_names entry in apm_config.features (pkg/trace/config/config.go:184); it is off by default.
  • When it is on, the obfuscator returns the tables in ObfuscatedQuery.Metadata.TablesCSV, and obfuscateSQLSpan writes them to sql.tables (pkg/trace/agent/obfuscate.go:131-132).
  • Reproduction against pkg/obfuscate: NewObfuscator(Config{SQL: SQLConfig{TableNames: true}}).ObfuscateSQLString("SELECT * FROM users JOIN orders ON users.id = 42") returns TablesCSV = "users,orders".

libdatadog behavior
SqlConfig (obfuscation_config.rs:271) has no table-names option, the SQL obfuscator returns only the query string, and obfuscate_span never writes sql.tables.

Describe the goal of the feature

  1. A table_names option on SqlConfig.
  2. The SQL obfuscator returns the table list alongside the query when it is on.
  3. obfuscate_span sets sql.tables when the list is non-empty, matching obfuscateSQLSpan.

Additional context
Found while moving Saluki's (ADP) trace obfuscation onto libdd-trace-obfuscation (DataDog/saluki#3032). Drafted with an AI coding assistant; the reproductions below were run against libdatadog e47926a34 and, for the Agent side, against pkg/obfuscate at datadog-agent 062c8b92d31.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions