Skip to content

DBMON-6617 Add CPU time and CPU wait to ClickHouse DBM payloads#23882

Draft
jenny-chung wants to merge 3 commits into
masterfrom
jenny-chung/clickhouse-cpu-time
Draft

DBMON-6617 Add CPU time and CPU wait to ClickHouse DBM payloads#23882
jenny-chung wants to merge 3 commits into
masterfrom
jenny-chung/clickhouse-cpu-time

Conversation

@jenny-chung
Copy link
Copy Markdown

@jenny-chung jenny-chung commented May 29, 2026

What does this PR do?

Surfaces CPU consumption alongside the existing wall-clock duration in both ClickHouse DBM pipelines.

  • statements.py (aggregated query metrics): adds cpu_us, cpu_wait_us, and a derived mean_cpu_us per query signature. Sourced from sum(ProfileEvents['OSCPUVirtualTimeMicroseconds']) and sum(ProfileEvents['OSCPUWaitMicroseconds']) over the collection window. Multi-node Cloud merge logic sums both new fields across nodes.
  • query_completions.py (per-execution samples): adds cpu_us and cpu_wait_us per individual query execution.

Both fields are in microseconds. No new configuration, no new agent-emitted metrics; these fields flow only through the existing DBM payloads via database_monitoring_query_metrics and database_monitoring_query_activity.

Motivation

DBMON-6617.

DBM collects completed queries and query metrics from the system.query_log table on ClickHouse. However, we do not collect the CPU time per query today, and this is an ask from a few of our customers.

ClickHouse records per-query CPU usage in system.query_log via the ProfileEvents map column:

  • OSCPUVirtualTimeMicroseconds — total CPU time consumed across all threads working on the query.
  • OSCPUWaitMicroseconds — CPU wait time (runnable but not on-CPU).

This PR surfaces both values as cpu_us and cpu_wait_us in the DBM payloads.

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/` label to the PR and it will automatically open a backport PR once this one is merged

@datadog-official
Copy link
Copy Markdown
Contributor

datadog-official Bot commented May 29, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Check PR | run / Check PR changelog   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. Release note not found during changelog validation for package 'clickhouse'.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 90.91%
Overall Coverage: 93.18%

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 39b60d7 | Docs | Datadog PR Page | Give us feedback!

@sangeetashivaji sangeetashivaji added the qa/required QA is required for this PR and will generate a QA card label May 29, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 29, 2026

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants