← Back to Pull requests

[Backport 7.84.x] Emit a single timeseries for DPA apply mode and controlled resources #56382

Closed
unknown closed this pull request without merging on Sep 16, 2026 18:52 UTC
View on GitHub
unknown unknown commented on Sep 15, 2026 16:47 UTC
Author

Backport 84d08f7447c9d53559e40befb7f8ef17eb97e992 from #56316.

___

<!-- dd-meta {"pullId":"00000000-0000-0000-0000-000000000000","source":"chat","resourceId":"6d2bc3b1-5fe3-4ea9-bf22-3c77c34937e4","workflowId":"0cc41a34-4840-4e2b-9bfb-334d5a56a036","codeChangeId":"0cc41a34-4840-4e2b-9bfb-334d5a56a036","sourceType":"chat"} -->

What does this PR do?

Makes the two Cluster Agent workload autoscaling metrics added in #55475 emit one timeseries per DPA (resp. per container constraint) instead of one per dimension/resource:

  • datadog.cluster_agent.autoscaling.workload.apply_mode now emits a single point carrying one dpa_dimension tag value per enabled dimension, so a multi-dimensional DPA is tagged with both dpa_dimension:horizontal and dpa_dimension:vertical. Nothing is emitted when both dimensions are disabled.

  • datadog.cluster_agent.autoscaling.workload.vertical_scaling.controlled_resources now emits a single point per enabled container constraint, carrying one resource_name tag value per controlled resource (for example both resource_name:cpu and resource_name:memory).
  • The metric documentation in pkg/clusteragent/autoscaling/workload/metrics/metrics.md is updated to describe the resulting cardinality.

    Motivation

    The previous implementation appended one point per enabled dimension and one point per controlled resource, which created several metric contexts for the same DPA. As a result a count over apply_mode double-counted multi-dimensional DPAs, and no single series identified a DPA that autoscales both dimensions; the same applied to a container controlling both CPU and memory.

    Because Datadog tag keys are multi-valued, keeping a single series preserves filtering (dpa_dimension:horizontal and resource_name:cpu still match the multi-valued series) while making counts correct. Deduplication of repeated resources, the skip for container constraints with enabled: false or an empty controlledResources list, and the kube_container_name:all wildcard mapping are unchanged.

    Describe how you validated your changes

  • Extended the table-driven generator tests: the multi-dimensional case now requires exactly one apply_mode point carrying both dimension tags (the previous assertion read only the first matching tag and would have passed either way), the preview case asserts the vertical tag is absent, and new cases cover vertical-only and both-dimensions-disabled (no point at all).

  • assertControlledResourcesMetrics now maps container to all its resource_name values and fails if a container appears in more than one series.

  • Added focused tests for the tag builders (TestApplyModeTags, TestControlledResourceTags) checking multi-valued tags, exact tag counts, and that the shared base tags are not mutated, plus an end-to-end TestGeneratePodAutoscalerMetricsSingleTimeseriesPerContext on a multi-dimensional DPA controlling CPU and memory.

  • Ran the package tests (kubeapiserver build tag): red against the pre-fix generator (metric counts 19 vs 17), green with the fix. dda inv test could not run in this environment (the pinned Go toolchain is not installed and the Bazel download is blocked by the proxy), so the tests were run through the Go toolchain directly with the same build tags.
  • Additional Notes

    N/A

    ---

    PR by Bits - View session in Datadog

    Comment @datadog to request changes

    Diff: 433 lines (+324 / -109) across 5 files Reviewer: AlexanderYastrebov Review duration: 1564m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 433 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #56382"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%