Move postgres async jobs onto the DatabaseCheck job registry - #24824
Merged
Conversation
Replace the hand-rolled _async_jobs property, _cancel_async_jobs helper and manual future/teardown loop with register_async_job, run_async_jobs, cancel_async_jobs and shutdown_async_jobs from DatabaseCheck. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
evalya-impact-summaryevalya impact analysis |
Contributor
🎉 All green!🧪 All tests passed 🚧 1 test that failed was ignored due to quarantine 🎯 Code Coverage (details) 🔗 Commit SHA: 3db9595 | Docs | Datadog PR Page | Give us feedback! |
Only construct the jobs the configuration enables, instead of building all four in __init__ and registering a subset. Unregistered jobs previously kept a back-reference to the check that shutdown_async_jobs() never cleared. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Validation ReportAll 21 validations passed. Show details
|
sethsamuel
approved these changes
Aug 11, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Migrates the postgres integration onto the async job registry that
DatabaseCheckgained in #24442 and that shipped indatadog_checks_base38.0.0.DBMAsyncJobinstances are registered throughregister_async_jobin a single_register_async_jobshelper that encodes the existingdbm/data_observability.enabledconditions.check()callsrun_async_jobs(tags)instead of repeating that condition chain around fourrun_job_loopcalls.cancel()callscancel_async_jobs()in place of the local_cancel_async_jobshelper._finalize()callsshutdown_async_jobs()instead of reaching into each job's private_job_loop_futureto wait on it and then invoking a private_shutdown()._shutdown()is renamed toshutdown(), the teardown hook the base class now calls on unschedule._initialize_statement_metricsre-registers after swapping inPostgresStatementMetricsV2. Both collectors use thequery-metricsjob name, so registration replaces the placeholder instance built in__init__before the server version is known.The
_cancel_lock/_is_running/_cancelleddeferred-finalize machinery is unchanged:cancel()still only signals, and destructive teardown still waits for an in-flightrun().Minimum
datadog-checks-baseis bumped to>=38.0.0for the registry methods.Motivation
First integration in the DBMON-6881 rollout of the job registry. Postgres was already the closest to the target shape, so it establishes the pattern that mysql, sqlserver and clickhouse will follow.
No behavior change is intended. The set of jobs that run, the order they run in, the tags they receive, and the cancel/teardown sequence all match what the removed code did.
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is mergedMade with Cursor