Skip to content

Add Battery Check for Mac#44371

Merged
dd-mergequeue[bot] merged 20 commits into
mainfrom
brian.tu/battery-check-mac
Dec 18, 2025
Merged

Add Battery Check for Mac#44371
dd-mergequeue[bot] merged 20 commits into
mainfrom
brian.tu/battery-check-mac

Conversation

@briantu

@briantu briantu commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Original PR (#43986) for adding the battery check was reverted (#44359) due to #incident-47253. The error was:

2025-12-17T16:18:24.181036Z 01O 
2025-12-17T16:18:24.181036Z 01O     # github.com/DataDog/datadog-agent/pkg/collector/corechecks/system/battery
2025-12-17T16:18:24.181037Z 01O battery_darwin.m:12:61: error: 'kIOMainPortDefault' is only available on macOS 12.0 or newer [-Werror,-Wunguarded-availability-new]
2025-12-17T16:18:24.181057Z 01O /Applications/Xcode-16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:112:19: note: 'kIOMainPortDefault' has been marked as being introduced in macOS 12.0 here, but the deployment target is macOS 11.0.0

This PR includes the fix that caused the incident.

  • kIOMainPortDefault was introduced in macOS 12.0, use kIOMasterPortDefault for older versions

Motivation

https://datadoghq.atlassian.net/browse/WINA-2068

Describe how you validated your changes

Ran full pipeline with the fix: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/pipelines/87391310/

Additional Notes

@briantu
briantu requested review from a team as code owners December 17, 2025 21:42
@github-actions github-actions Bot added long review PR is complex, plan time to review it team/windows-products labels Dec 17, 2025
@briantu briantu added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests ask-review Ask in slack required teams to review this PR labels Dec 17, 2025
@agent-platform-auto-pr

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 5175db7

Successful checks

Info

Quality gate Delta On disk size (MiB) Delta On wire size (MiB)
agent_deb_amd64 $${+0}$$ $${706.33}$$ < $${707.13}$$ $${-0.01}$$ $${173.28}$$ < $${174.16}$$
agent_deb_amd64_fips $${+0}$$ $${702.55}$$ < $${702.86}$$ $${-0}$$ $${172.63}$$ < $${173.5}$$
agent_heroku_amd64 $${+0}$$ $${327.51}$$ < $${327.92}$$ $${+0}$$ $${87.23}$$ < $${88.21}$$
agent_msi $${0}$$ $${570.41}$$ < $${982.08}$$ $${-0.01}$$ $${142.48}$$ < $${143.49}$$
agent_rpm_amd64 $${+0}$$ $${706.32}$$ < $${707.12}$$ $${-0.02}$$ $${176.38}$$ < $${177.29}$$
agent_rpm_amd64_fips $${+0}$$ $${702.54}$$ < $${702.85}$$ $${+0.01}$$ $${175.41}$$ < $${176.32}$$
agent_rpm_arm64 $${+0}$$ $${688.02}$$ < $${691.67}$$ $${-0}$$ $${159.42}$$ < $${160.7}$$
agent_rpm_arm64_fips $${+0.01}$$ $${685.07}$$ < $${687.54}$$ $${-0.01}$$ $${159.16}$$ < $${160.11}$$
agent_suse_amd64 $${+0}$$ $${706.32}$$ < $${707.12}$$ $${-0.02}$$ $${176.38}$$ < $${177.29}$$
agent_suse_amd64_fips $${+0}$$ $${702.54}$$ < $${702.85}$$ $${+0.01}$$ $${175.41}$$ < $${176.32}$$
agent_suse_arm64 $${+0}$$ $${688.02}$$ < $${691.67}$$ $${-0}$$ $${159.42}$$ < $${160.7}$$
agent_suse_arm64_fips $${+0.01}$$ $${685.07}$$ < $${687.54}$$ $${-0.01}$$ $${159.16}$$ < $${160.11}$$
docker_agent_amd64 $${+0.02}$$ $${768.59}$$ < $${769.38}$$ $${-0.02}$$ $${261.15}$$ < $${262.06}$$
docker_agent_arm64 $${+0.02}$$ $${774.83}$$ < $${778.35}$$ $${-0}$$ $${250.27}$$ < $${251.72}$$
docker_agent_jmx_amd64 $${+0.02}$$ $${959.47}$$ < $${960.26}$$ $${-0.02}$$ $${329.78}$$ < $${330.69}$$
docker_agent_jmx_arm64 $${+0.01}$$ $${954.43}$$ < $${957.95}$$ $${-0.02}$$ $${314.88}$$ < $${316.35}$$
docker_cluster_agent_amd64 $${+0}$$ $${179.41}$$ < $${179.56}$$ $${-0}$$ $${63.44}$$ < $${64.14}$$
docker_cluster_agent_arm64 $${+0.01}$$ $${195.37}$$ < $${196.79}$$ $${+0.01}$$ $${59.76}$$ < $${60.69}$$
docker_cws_instrumentation_amd64 $${0}$$ $${7.13}$$ < $${7.18}$$ $${+0}$$ $${2.99}$$ < $${3.33}$$
docker_cws_instrumentation_arm64 $${0}$$ $${6.69}$$ < $${6.92}$$ $${+0}$$ $${2.73}$$ < $${3.09}$$
docker_dogstatsd_amd64 $${0}$$ $${38.75}$$ < $${39.38}$$ $${+0}$$ $${15.0}$$ < $${15.82}$$
docker_dogstatsd_arm64 $${+0}$$ $${37.06}$$ < $${37.94}$$ $${+0}$$ $${14.33}$$ < $${14.83}$$
dogstatsd_deb_amd64 $${0}$$ $${29.97}$$ < $${30.61}$$ $${-0}$$ $${7.93}$$ < $${8.79}$$
dogstatsd_deb_arm64 $${0}$$ $${28.13}$$ < $${29.11}$$ $${+0}$$ $${6.81}$$ < $${7.71}$$
dogstatsd_rpm_amd64 $${0}$$ $${29.97}$$ < $${30.61}$$ $${-0}$$ $${7.94}$$ < $${8.8}$$
dogstatsd_suse_amd64 $${0}$$ $${29.97}$$ < $${30.61}$$ $${-0}$$ $${7.94}$$ < $${8.8}$$
iot_agent_deb_amd64 $${0}$$ $${42.73}$$ < $${43.29}$$ $${+0}$$ $${11.19}$$ < $${12.04}$$
iot_agent_deb_arm64 $${+0}$$ $${39.87}$$ < $${40.92}$$ $${+0}$$ $${9.58}$$ < $${10.45}$$
iot_agent_deb_armhf $${+0}$$ $${40.44}$$ < $${41.03}$$ $${+0}$$ $${9.77}$$ < $${10.62}$$
iot_agent_rpm_amd64 $${0}$$ $${42.73}$$ < $${43.29}$$ $${+0}$$ $${11.21}$$ < $${12.06}$$
iot_agent_suse_amd64 $${0}$$ $${42.73}$$ < $${43.29}$$ $${+0}$$ $${11.21}$$ < $${12.06}$$

@cit-pr-commenter

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 85273c08-7b9f-4ffa-8d4b-35d2a0b14265

Baseline: 5175db7
Comparison: c0223bd
Diff

Optimization Goals: ✅ Improvement(s) detected

perf experiment goal Δ mean % Δ mean % CI trials links
tcp_syslog_to_blackhole ingress throughput +12.23 [+12.13, +12.34] 1 Logs
quality_gate_metrics_logs memory utilization -6.22 [-6.42, -6.01] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -18.44 [-19.80, -17.09] 1 Logs bounds checks dashboard

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI trials links
docker_containers_cpu % cpu utilization -3.61 [-6.55, -0.68] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
tcp_syslog_to_blackhole ingress throughput +12.23 [+12.13, +12.34] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.07, +0.08] 1 Logs
uds_dogstatsd_to_api_v3 ingress throughput -0.01 [-0.15, +0.13] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.02 [-0.16, +0.12] 1 Logs
file_to_blackhole_1000ms_latency egress throughput -0.08 [-0.48, +0.32] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.16 [-0.20, -0.11] 1 Logs
file_to_blackhole_500ms_latency egress throughput -0.16 [-0.55, +0.24] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.21 [-0.75, +0.33] 1 Logs
ddot_metrics_sum_cumulativetodelta_exporter memory utilization -0.80 [-1.03, -0.57] 1 Logs
ddot_metrics memory utilization -0.85 [-1.07, -0.63] 1 Logs
ddot_metrics_sum_cumulative memory utilization -1.00 [-1.16, -0.84] 1 Logs
docker_containers_memory memory utilization -1.16 [-1.23, -1.10] 1 Logs
ddot_logs memory utilization -1.46 [-1.53, -1.39] 1 Logs
ddot_metrics_sum_delta memory utilization -1.48 [-1.67, -1.29] 1 Logs
otlp_ingest_logs memory utilization -1.64 [-1.74, -1.53] 1 Logs
quality_gate_idle_all_features memory utilization -2.29 [-2.32, -2.26] 1 Logs bounds checks dashboard
uds_dogstatsd_20mb_12k_contexts_20_senders memory utilization -2.64 [-2.70, -2.59] 1 Logs
quality_gate_idle memory utilization -2.81 [-2.85, -2.76] 1 Logs bounds checks dashboard
file_tree memory utilization -2.93 [-2.99, -2.86] 1 Logs
docker_containers_cpu % cpu utilization -3.61 [-6.55, -0.68] 1 Logs
otlp_ingest_metrics memory utilization -3.82 [-3.96, -3.67] 1 Logs
quality_gate_metrics_logs memory utilization -6.22 [-6.42, -6.01] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -18.44 [-19.80, -17.09] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
docker_containers_cpu simple_check_run 10/10
docker_containers_memory memory_usage 10/10
docker_containers_memory simple_check_run 10/10
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency lost_bytes 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency lost_bytes 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10 bounds checks dashboard
quality_gate_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_logs memory_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 bounds checks dashboard
quality_gate_metrics_logs lost_bytes 10/10 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

Replicate Execution Details

We run multiple replicates for each experiment/variant. However, we allow replicates to be automatically retried if there are any failures, up to 8 times, at which point the replicate is marked dead and we are unable to run analysis for the entire experiment. We call each of these attempts at running replicates a replicate execution. This section lists all replicate executions that failed due to the target crashing or being oom killed.

Note: In the below tables we bucket failures by experiment, variant, and failure type. For each of these buckets we list out the replicate indexes that failed with an annotation signifying how many times said replicate failed with the given failure mode. In the below example the baseline variant of the experiment named experiment_with_failures had two replicates that failed by oom kills. Replicate 0, which failed 8 executions, and replicate 1 which failed 6 executions, all with the same failure mode.

Experiment Variant Replicates Failure Logs Debug Dashboard
experiment_with_failures baseline 0 (x8) 1 (x6) Oom killed Debug Dashboard

The debug dashboard links will take you to a debugging dashboard specifically designed to investigate replicate execution failures.

❌ Retried Profiling Replicate Execution Failures (ddprof)

Note: Profiling replicas may still be executing. See the debug dashboard for up to date status.

Experiment Variant Replicates Failure Debug Dashboard
docker_containers_cpu baseline 10 Crashed (exit code: 0) Debug Dashboard

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@briantu briantu removed the changelog/no-changelog No changelog entry needed label Dec 17, 2025

@julien-lebot julien-lebot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the agent_dmg-x64-a7 and the agent_dmg-arm64-a7 jobs have passed, approving.

@briantu

briantu commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Dec 18, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-12-18 17:25:02 UTC ℹ️ Start processing command /merge


2025-12-18 17:25:08 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 1h (p90).


2025-12-18 19:21:57 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue
dd-mergequeue Bot merged commit cb74d8b into main Dec 18, 2025
360 of 361 checks passed
@dd-mergequeue
dd-mergequeue Bot deleted the brian.tu/battery-check-mac branch December 18, 2025 19:21
@github-actions github-actions Bot added this to the 7.75.0 milestone Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ask-review Ask in slack required teams to review this PR long review PR is complex, plan time to review it qa/done QA done before merge and regressions are covered by tests team/windows-products

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants