Skip to content

Commit 1befb90

Browse files
authored
Enable schema collection for Postgres by default (DataDog#23626)
* Enable schema collection for Postgres by default * Changelog * Fix test * Fix tests * Disable collect schemas in statement tests * lint * Disable collect schemas in statement tests * Disable collect schemas in statement tests * Disable collect schemas in statement tests * Disable collect schemas in statement tests * Disable collect schemas in statement tests * Changelog
1 parent 0ff244d commit 1befb90

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

postgres/assets/configuration/spec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ files:
953953
Enable collection of database schemas. Requires `dbm: true`.
954954
value:
955955
type: boolean
956-
example: false
956+
example: true
957957
- name: max_tables
958958
fleet_configurable: true
959959
description: |

postgres/changelog.d/23626.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable schema collection for Postgres by default. This functionality still requires `dbm:true` or `data_observability.enabled:true`. To disable, set `collect_schemas.enabled: false`.

postgres/datadog_checks/postgres/config_models/dict_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def instance_collect_settings():
8686

8787
def instance_collect_schemas():
8888
return instance.CollectSchemas(
89-
enabled=False,
89+
enabled=True,
9090
max_tables=300,
9191
max_columns=50,
9292
collection_interval=600,

postgres/datadog_checks/postgres/data/conf.yaml.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,10 @@ instances:
593593
#
594594
# collect_schemas:
595595

596-
## @param enabled - boolean - optional - default: false
596+
## @param enabled - boolean - optional - default: true
597597
## Enable collection of database schemas. Requires `dbm: true`.
598598
#
599-
# enabled: false
599+
# enabled: true
600600

601601
## @param max_tables - number - optional - default: 300
602602
## Maximum amount of tables the Agent collects from the instance.

postgres/tests/test_config_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
},
116116
# === DBM: Schema collection ===
117117
'collect_schemas': {
118-
'enabled': False,
118+
'enabled': True,
119119
'max_tables': 300,
120120
'max_columns': 50,
121121
'collection_interval': 600,

postgres/tests/test_statements.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_statement_metrics_multiple_pgss_rows_single_query_signature(
8989
# don't need samples for this test
9090
dbm_instance['query_samples'] = {'enabled': False}
9191
dbm_instance['query_activity'] = {'enabled': False}
92+
dbm_instance['collect_schemas'] = {'enabled': False}
9293
dbm_instance['query_metrics']['incremental_query_metrics'] = True
9394
connections = {}
9495

@@ -232,6 +233,7 @@ def test_statement_metrics(
232233
# don't need samples for this test
233234
dbm_instance['query_samples'] = {'enabled': False}
234235
dbm_instance['query_activity'] = {'enabled': False}
236+
dbm_instance['collect_schemas'] = {'enabled': False}
235237
connections = {}
236238

237239
def _run_queries():
@@ -339,6 +341,7 @@ def test_wal_metrics(aggregator, integration_check, dbm_instance):
339341
# don't need samples for this test
340342
dbm_instance['query_samples'] = {'enabled': False}
341343
dbm_instance['query_activity'] = {'enabled': False}
344+
dbm_instance['collect_schemas'] = {'enabled': False}
342345

343346
connections = {}
344347

@@ -372,6 +375,7 @@ def test_statement_metrics_with_duplicates(aggregator, integration_check, dbm_in
372375
# don't need samples for this test
373376
dbm_instance['query_samples'] = {'enabled': False}
374377
dbm_instance['query_activity'] = {'enabled': False}
378+
dbm_instance['collect_schemas'] = {'enabled': False}
375379

376380
# The query signature matches the normalized query returned by the mock agent and would need to be
377381
# updated if the normalized query is updated
@@ -481,6 +485,8 @@ def test_successful_explain(
481485
# Don't need metrics for this one
482486
dbm_instance['query_metrics']['enabled'] = False
483487
dbm_instance['query_samples']['explain_parameterized_queries'] = False
488+
dbm_instance['collect_schemas'] = {'enabled': False}
489+
484490
check = integration_check(dbm_instance)
485491
check._connect()
486492

@@ -563,6 +569,7 @@ def test_failed_explain_handling(
563569
# Don't need metrics for this one
564570
dbm_instance['query_metrics']['enabled'] = False
565571
dbm_instance['query_samples']['explain_parameterized_queries'] = False
572+
dbm_instance['collect_schemas'] = {'enabled': False}
566573
if explain_function_override:
567574
dbm_instance['query_samples']['explain_function'] = explain_function_override
568575
check = integration_check(dbm_instance)
@@ -715,6 +722,7 @@ def test_statement_samples_collect(
715722
):
716723
dbm_instance['pg_stat_activity_view'] = pg_stat_activity_view
717724
dbm_instance['query_metrics']['enabled'] = False
725+
dbm_instance['collect_schemas'] = {'enabled': False}
718726
dbm_instance['dbstrict'] = dbstrict
719727
dbm_instance['dbname'] = dbname
720728
dbm_instance['ignore_databases'] = ignore_databases
@@ -830,6 +838,7 @@ def test_statement_metadata(
830838
"""Tests for metadata in both samples and metrics"""
831839
dbm_instance['pg_stat_statements_view'] = pg_stat_statements_view
832840
dbm_instance['query_metrics']['run_sync'] = True
841+
dbm_instance['collect_schemas'] = {'enabled': False}
833842

834843
# If query or normalized_query changes, the query_signatures for both will need to be updated as well.
835844
query = '''
@@ -911,6 +920,7 @@ def test_statement_reported_hostname(
911920
expected_hostname,
912921
):
913922
dbm_instance['reported_hostname'] = reported_hostname
923+
dbm_instance['collect_schemas'] = {'enabled': False}
914924

915925
check = integration_check(dbm_instance)
916926

@@ -1353,6 +1363,7 @@ def test_statement_run_explain_errors(
13531363
dbm_instance['query_activity']['enabled'] = False
13541364
dbm_instance['query_metrics']['enabled'] = False
13551365
dbm_instance['query_samples']['explain_parameterized_queries'] = False
1366+
dbm_instance['collect_schemas'] = {'enabled': False}
13561367
check = integration_check(dbm_instance)
13571368
check._connect()
13581369

@@ -1405,6 +1416,7 @@ def test_statement_run_explain_parameterized_queries(
14051416
dbm_instance['query_activity']['enabled'] = False
14061417
dbm_instance['query_metrics']['enabled'] = False
14071418
dbm_instance['query_samples']['explain_parameterized_queries'] = True
1419+
dbm_instance['collect_schemas'] = {'enabled': False}
14081420
check = integration_check(dbm_instance)
14091421
check._connect()
14101422

@@ -1988,6 +2000,7 @@ def test_plan_time_metrics(aggregator, integration_check, dbm_instance):
19882000
# don't need samples for this test
19892001
dbm_instance['query_samples'] = {'enabled': False}
19902002
dbm_instance['query_activity'] = {'enabled': False}
2003+
dbm_instance['collect_schemas'] = {'enabled': False}
19912004

19922005
connections = {}
19932006

@@ -2079,6 +2092,7 @@ def test_metrics_encoding(
20792092
dbm_instance['query_encodings'] = ['latin1', 'utf-8']
20802093
dbm_instance['query_samples'] = {'enabled': False}
20812094
dbm_instance['query_activity'] = {'enabled': False}
2095+
dbm_instance['collect_schemas'] = {'enabled': False}
20822096
# dbm_instance['query_activity']['enabled'] = False
20832097
check = integration_check(dbm_instance)
20842098
check._connect()
@@ -2114,6 +2128,7 @@ def test_samples_encoding(
21142128
dbm_instance,
21152129
):
21162130
dbm_instance['query_metrics']['enabled'] = False
2131+
dbm_instance['collect_schemas'] = {'enabled': False}
21172132
if POSTGRES_LOCALE == 'C':
21182133
dbm_instance['query_encodings'] = ['latin1', 'utf-8']
21192134
check = integration_check(dbm_instance)

0 commit comments

Comments
 (0)