Skip to content

Commit a85074c

Browse files
authored
Backfill old keys used in SQL obfuscator (DataDog#21557)
* Backill old keys used in SQL obfuscator * Changelog * Typo
1 parent 1567202 commit a85074c

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

postgres/changelog.d/21557.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Backfill old keys in options passed from Postgres integration to SQL obfuscator

postgres/datadog_checks/postgres/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ def build_config(check: PostgreSql) -> Tuple[InstanceConfig, ValidationResult]:
178178
}
179179
)
180180

181+
# Backfill old key to new key
182+
if instance.get('obfuscator_options', {}).get('quantize_sql_tables'):
183+
args['obfuscator_options']['replace_digits'] = True
184+
181185
validation_result = ValidationResult()
182186

183187
# Generate and validate tags

postgres/datadog_checks/postgres/statement_samples.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ def __init__(self, check: PostgreSql, config: InstanceConfig):
173173
# The value is loaded when connecting to the main database
174174
self._explain_function = config.query_samples.explain_function
175175
self._explain_parameterized_queries = ExplainParameterizedQueries(check, config, self._explain_function)
176-
self._obfuscate_options = to_native_string(self._config.obfuscator_options.model_dump_json())
176+
obfuscate_options = self._config.obfuscator_options.model_dump()
177+
# Backfill old keys used in the agent obfuscator
178+
obfuscate_options['table_names'] = self._config.obfuscator_options.collect_tables
179+
obfuscate_options['dollar_quoted_func'] = self._config.obfuscator_options.keep_dollar_quoted_func
180+
obfuscate_options['return_json_metadata'] = self._config.obfuscator_options.collect_metadata
181+
self._obfuscate_options = to_native_string(json.dumps(obfuscate_options))
182+
177183
self._collect_raw_query_statement = config.collect_raw_query_statement.enabled
178184

179185
self._collection_strategy_cache = TTLCache(

postgres/datadog_checks/postgres/statements.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ def __init__(self, check, config: InstanceConfig):
185185
self._baseline_metrics = {}
186186
self._last_baseline_metrics_expiry = None
187187
self._track_io_timing_cache = None
188-
self._obfuscate_options = to_native_string(self._config.obfuscator_options.model_dump_json())
188+
obfuscate_options = self._config.obfuscator_options.model_dump()
189+
# Backfill old keys used in the agent obfuscator
190+
obfuscate_options['table_names'] = self._config.obfuscator_options.collect_tables
191+
obfuscate_options['dollar_quoted_func'] = self._config.obfuscator_options.keep_dollar_quoted_func
192+
obfuscate_options['return_json_metadata'] = self._config.obfuscator_options.collect_metadata
193+
self._obfuscate_options = to_native_string(json.dumps(obfuscate_options))
189194
# full_statement_text_cache: limit the ingestion rate of full statement text events per query_signature
190195
self._full_statement_text_cache = TTLCache(
191196
maxsize=config.query_metrics.full_statement_text_cache_max_size,

0 commit comments

Comments
 (0)