Skip to content

Collect PostgreSQL view schema metadata - #24972

Draft
mobuchowski wants to merge 4 commits into
mobuchowski/schema-collector-count-telemetryfrom
mobuchowski/postgres-view-schema-metadata
Draft

Collect PostgreSQL view schema metadata#24972
mobuchowski wants to merge 4 commits into
mobuchowski/schema-collector-count-telemetryfrom
mobuchowski/postgres-view-schema-metadata

Conversation

@mobuchowski

@mobuchowski mobuchowski commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a dedicated PostgreSQL view collector that runs alongside table schema collection and emits a separate pg_views DBM metadata payload. Each schema contains an empty tables array and a populated views array. Regular and materialized views include their ID, name, owner, reconstructed definition, relation kind, and table-compatible column metadata.

Adds collect_views, enabled by default, and an independent max_views limit of 1000. Existing pg_databases collection, table queries, filters, and connection handling remain unchanged. View counts are reported as dd.postgres.schema.views_count.

Shared telemetry dependency: #24947

Companion backend change: https://github.com/ddoghq/dd-go/pull/12199

Motivation

PostgreSQL schema collection currently discovers only ordinary, partitioned, and foreign tables. UGP needs regular and materialized view definitions and projected columns without treating those objects as physical tables or applying the table limit to them.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 25, 2026

Copy link
Copy Markdown

Tests

⚠️ Warnings

⚠️ Your PR has warnings. Please review the issues below.

❄️ 1 New flaky test detected

test_schema_collectors_report_separate_object_counts[PostgresViewCollector-dd.postgres.schema.views_count-dd.postgres.schema.tables_count] from test_unit.py
assert &#39;dd.postgres.schema.views_count&#39; in {&#39;dd.postgres.schema.tables_count&#39;, &#39;dd.postgres.schema.payloads_count&#39;}

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🚧 3 tests that failed were ignored due to quarantine View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dff8383 | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 25, 2026

Copy link
Copy Markdown

evalya-impact-summary

evalya impact analysis
Impact analysis: 0 selected, 0 skipped (of 0 test tasks)
Publish tasks:   1 (always emitted)
Diff (13 files):
  datadog_checks_base/changelog.d/24947.fixed
  datadog_checks_base/datadog_checks/base/utils/db/schemas.py
  postgres/assets/configuration/spec.yaml
  postgres/changelog.d/24972.added
  postgres/datadog_checks/postgres/config.py
  postgres/datadog_checks/postgres/config_models/instance.py
  postgres/datadog_checks/postgres/data/conf.yaml.example
  postgres/datadog_checks/postgres/metadata.py
  postgres/datadog_checks/postgres/views.py
  postgres/tests/compose/resources/02_load_data.sh
  postgres/tests/test_config_defaults.py
  postgres/tests/test_metadata.py
  postgres/tests/test_unit.py

Debug a specific task: evalya plan impact --path <path> --task <task>

Learn more about CI impact filtering

@mobuchowski mobuchowski added the qa/required QA is required for this PR and will generate a QA card label Aug 25, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation integration/postgres qa/required QA is required for this PR and will generate a QA card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant