Skip to content

Populate Network Path metadata for CNM connections - #52902

Draft
AlexandreYang wants to merge 13 commits into
mainfrom
alex/cnm-netpath-agent
Draft

Populate Network Path metadata for CNM connections#52902
AlexandreYang wants to merge 13 commits into
mainfrom
alex/cnm-netpath-agent

Conversation

@AlexandreYang

@AlexandreYang AlexandreYang commented Jun 27, 2026

Copy link
Copy Markdown
Member

Summary

  • document the CNM -> Network Path enrichment design in Confluence
  • return per-connection npmodel.NetworkPath values from NPCollector scheduling paths
  • populate Connection.NetworkPath.HasTest on evaluated CNM connections using the collector result
  • bump github.com/DataDog/agent-payload/v5 to the companion payload schema with Connection.NetworkPath.HasTest

Companion PR

Health Platform issue state note

The agent-payload bump also regenerates the Health Platform proto definitions. In that regenerated code, ISSUE_STATE_NEW and ISSUE_STATE_ONGOING are deprecated; ISSUE_STATE_ACTIVE and ISSUE_STATE_RESOLVED are the canonical values going forward.

This PR updates Agent Health Platform code and tests to emit and assert ISSUE_STATE_ACTIVE for active issues, while still loading legacy persisted new/ongoing states as active. This is not part of the CNM Network Path runtime behavior, but it is required so the Agent continues to pass staticcheck after consuming the updated agent-payload module.

Tests

  • git diff --check
  • GOPROXY=https://proxy.golang.org,direct dda inv go.tidy
  • GOPROXY=https://proxy.golang.org,direct dda inv test --targets=./pkg/process/checks --extra-args='-run TestScheduleNetworkPathSetsConnectionMetadata'
  • GOPROXY=https://proxy.golang.org,direct dda inv test --targets=./comp/networkpath/npcollector/impl --extra-args='-run Test_npCollectorImpl_ScheduleNetworkPathTests'

Note: parallel dda inv test attempts for npcollector can fail before running tests due to a local dda temporary uv-* cleanup race; the same command passed when rerun by itself.

@AlexandreYang
AlexandreYang requested review from a team as code owners June 27, 2026 19:38
@AlexandreYang
AlexandreYang requested review from qsl73 and removed request for a team June 27, 2026 19:38
@github-actions github-actions Bot added the medium review PR review might take time label Jun 27, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7bc40e5460

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

connCount++
if !s.shouldScheduleNetworkPathForConn(conn, origin, vpcSubnets) {
hasTest := s.shouldScheduleNetworkPathForConn(conn, origin, vpcSubnets)
decisions = append(decisions, npmodel.NetworkPathScheduleDecision{HasTest: hasTest})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid collecting decisions for ignored scheduling calls

When Network Path scheduling runs from the current production call sites I checked (comp/netflow/flowaggregator/aggregator.go:204, pkg/network/sender/sender_linux.go:324, and pkg/process/checks/net.go:185), the returned decisions are discarded. This append still allocates a backing slice for every yielded connection; in the NetFlow path it happens once per flow, so enabling network_path.netflow_monitoring adds an allocation on every flow even though no enrichment is populated yet. Please keep the old no-result scheduling path or make decision collection opt-in until a caller consumes it.

Useful? React with 👍 / 👎.

@AlexandreYang
AlexandreYang requested a review from a team as a code owner June 27, 2026 19:55
@github-actions github-actions Bot added long review PR is complex, plan time to review it and removed medium review PR review might take time labels Jun 27, 2026
@AlexandreYang AlexandreYang changed the title Add Network Path schedule decisions for CNM enrichment Populate Network Path metadata for CNM connections Jun 27, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11ed778918

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/process/checks/net.go
Comment on lines +266 to +268
scheduledConns[i].NetworkPath = &model.NetworkPath{
HasTest: decision.HasTest,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Plumb Network Path decisions through direct sender

Setting NetworkPath here only enriches the process-agent connections check path. In environments with network_config.direct_send: true, ConnectionsCheck.IsEnabled returns false (pkg/process/checks/net.go:143) and the Linux direct sender is the producer; that path still calls ScheduleNetworkPathTests and discards the returned decisions (pkg/network/sender/sender_linux.go:324), while encodeConnection never writes a network-path field. Those direct-send CNM deployments will schedule tests but continue sending connections without network_path.has_test, so please carry the decisions into the direct sender encoder as well.

Useful? React with 👍 / 👎.

@AlexandreYang
AlexandreYang marked this pull request as draft June 27, 2026 20:03
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 72.73%
Overall Coverage: 51.10% (-4.59%)

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

@dd-octo-sts

dd-octo-sts Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 1d93f4e9:

Results for datadog-agent_7.82.0~devel.git.442.5de868d.pipeline.121530583-1_amd64.deb:

No change detected

@dd-octo-sts

dd-octo-sts Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 1d93f4e
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +64.82 KiB (0.01% increase, -0.64% of buffer) 748.299 → 748.362 → 758.200
agent_deb_amd64_fips +68.79 KiB (0.01% increase, -1.12% of buffer) 703.865 → 703.932 → 709.840
agent_heroku_amd64 +20.25 KiB (0.01% increase, -0.30% of buffer) 308.717 → 308.736 → 315.230
agent_msi +64.5 KiB (0.01% increase, -0.49% of buffer) 617.659 → 617.722 → 630.600
agent_rpm_amd64 +64.82 KiB (0.01% increase, -0.64% of buffer) 748.283 → 748.346 → 758.170
agent_rpm_amd64_fips +68.79 KiB (0.01% increase, -1.12% of buffer) 703.849 → 703.916 → 709.840
agent_rpm_arm64 +57.26 KiB (0.01% increase, -0.96% of buffer) 723.822 → 723.878 → 729.660
agent_rpm_arm64_fips +61.23 KiB (0.01% increase, -1.02% of buffer) 683.023 → 683.083 → 688.860
agent_suse_amd64 +64.82 KiB (0.01% increase, -0.64% of buffer) 748.283 → 748.346 → 758.170
agent_suse_amd64_fips +68.79 KiB (0.01% increase, -1.12% of buffer) 703.849 → 703.916 → 709.840
agent_suse_arm64 +57.26 KiB (0.01% increase, -0.96% of buffer) 723.822 → 723.878 → 729.660
agent_suse_arm64_fips +61.23 KiB (0.01% increase, -1.02% of buffer) 683.023 → 683.083 → 688.860
docker_agent_amd64 +64.79 KiB (0.01% increase, -0.95% of buffer) 807.121 → 807.184 → 813.790
docker_agent_arm64 +57.24 KiB (0.01% increase, -0.76% of buffer) 807.677 → 807.733 → 815.030
docker_agent_jmx_amd64 +64.79 KiB (0.01% increase, -0.97% of buffer) 998.018 → 998.082 → 1004.550
docker_agent_jmx_arm64 +57.24 KiB (0.01% increase, -0.75% of buffer) 987.227 → 987.283 → 994.710
docker_cluster_agent_amd64 +16.15 KiB (0.01% increase, -0.81% of buffer) 208.530 → 208.546 → 210.470
iot_agent_deb_amd64 +24.22 KiB (0.05% increase, -3.45% of buffer) 45.695 → 45.719 → 46.380
iot_agent_deb_arm64 +20.22 KiB (0.05% increase, -1.51% of buffer) 42.414 → 42.434 → 43.720
iot_agent_deb_armhf +24.16 KiB (0.05% increase, -3.10% of buffer) 43.199 → 43.223 → 43.960
iot_agent_rpm_amd64 +24.22 KiB (0.05% increase, -3.46% of buffer) 45.696 → 45.720 → 46.380
iot_agent_suse_amd64 +24.22 KiB (0.05% increase, -3.45% of buffer) 45.695 → 45.718 → 46.380
11 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
docker_cluster_agent_arm64 221.753 MiB
docker_cws_instrumentation_amd64 7.447 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.032 MiB
docker_dogstatsd_arm64 37.180 MiB
docker_host_profiler_amd64 305.308 MiB
docker_host_profiler_arm64 316.411 MiB
dogstatsd_deb_amd64 29.763 MiB
dogstatsd_deb_arm64 27.822 MiB
dogstatsd_rpm_amd64 29.763 MiB
dogstatsd_suse_amd64 29.763 MiB

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Jun 27, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 29accbf1-d6cd-452f-9c59-2e77ad2143d2

Baseline: 1d93f4e
Comparison: 5de868d
Diff

❌ Experiments with retried target crashes

This is a critical error. One or more replicates failed with a non-zero exit code. These replicates may have been retried. See Replicate Execution Details for more information.

  • quality_gate_idle

Optimization Goals: ✅ Improvement(s) detected

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_metrics_logs memory utilization -6.71 [-6.94, -6.48] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -47.13 [-47.95, -46.30] 1 Logs bounds checks dashboard

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_idle_all_features memory utilization -2.76 [-2.79, -2.73] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization -3.13 [-3.18, -3.08] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -3.63 [-3.66, -3.59] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -3.69 [-3.79, -3.60] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization -3.71 [-3.77, -3.66] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization -6.71 [-6.94, -6.48] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -47.13 [-47.95, -46.30] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 145.67MiB ≤ 154MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 576.98KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 3 ≤ 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 489.64MiB ≤ 495MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 0.89MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 4 ≤ 6 bounds checks dashboard
quality_gate_logs memory_usage 10/10 180.93MiB ≤ 195MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 264.19MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 332.60 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 3 ≤ 6 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 391.67MiB ≤ 430MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.86GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 28.38 ≤ 40 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 293.69MiB ≤ 330MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 60.62 ≤ 80 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 275.47MiB ≤ 310MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 23.09 ≤ 40 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 283.52MiB ≤ 320MiB 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 Normal Replicate Execution Failures (non-profiling)

Experiment Variant Replicates Failure Debug Dashboard
quality_gate_idle baseline 7 Oom killed Debug Dashboard

❌ 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
quality_gate_idle baseline 10 Oom killed Debug Dashboard
quality_gate_idle_all_features baseline 10 Oom killed Debug Dashboard
quality_gate_idle_all_features comparison 10 Oom killed Debug Dashboard
quality_gate_logs baseline 10 Oom killed Debug Dashboard
quality_gate_logs comparison 10 Oom killed Debug Dashboard
quality_gate_metrics_logs baseline 10 Oom killed Debug Dashboard
quality_gate_metrics_logs comparison 10 Oom killed Debug Dashboard
quality_gate_security_idle baseline 10 Oom killed Debug Dashboard
quality_gate_security_no_fs_load comparison 10 Oom killed Debug Dashboard

CI Pass/Fail Decision

Passed. All Quality Gates 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_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 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 missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 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_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

@AlexandreYang AlexandreYang added the changelog/no-changelog No changelog entry needed label Jun 27, 2026
@AlexandreYang AlexandreYang added the qa/done QA done before merge and regressions are covered by tests label Jun 28, 2026
ScheduleNetflowPathTests(conns iter.Seq[npmodel.NetworkPathConnection])
// ScheduleNetworkPathTests schedules dynamic Network Path tests for CNM
// connections and returns one NetworkPath per yielded connection.
ScheduleNetworkPathTests(conns iter.Seq[npmodel.NetworkPathConnection]) []npmodel.NetworkPath

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I do not have all the context so feel free to ignore.

What if instead of returning a slice we return an iterator with the npmodel.NetworkPathConnection like:

ScheduleNetworkPathTests(conns iter.Seq[npmodel.NetworkPathConnection]) iter.Seq2[npmodel.NetworkPathConnection, npmodel.NetworkPath]

That way we can get rid of the two arrays synced together: networkPaths and scheduledConns.

Implementation — yield each pair lazily as connections are processed:

func (s *npCollectorImpl) scheduleNetworkPathTests(...) iter.Seq2[npmodel.NetworkPathConnection, npmodel.NetworkPath] {
    return func(yield func(npmodel.NetworkPathConnection, npmodel.NetworkPath) bool) {
        // ... getVPCSubnets, startTime setup ...
        for conn := range conns {
            var path npmodel.NetworkPath
            if s.shouldScheduleNetworkPathForConn(conn, origin, vpcSubnets) {
                pathtest := s.makePathtest(conn, origin)
                path = npmodel.NetworkPath{HasTest: true, TestIdentity: makeTestIdentity(...)}
                if err := s.scheduleOne(&pathtest); err != nil {
                    s.logger.Errorf(...)
                }
            }
            if !yield(conn, path) {
                return
            }
        }
        // emit timing/count metrics
    }
}

Consumer in net.go — drops to one parallel slice instead of two, gets npc directly from the range:

func (c *ConnectionsCheck) scheduleNetworkPath(conns *model.Connections) {
    var scheduledModelConns []*model.Connection
    connsIter := func(yield func(npmodel.NetworkPathConnection) bool) {
        for _, conn := range conns.Conns {
            // ... build npc, parse IPs ...
            if !yield(npc) { return }
            scheduledModelConns = append(scheduledModelConns, conn)
        }
    }
    i := 0
    for npc, path := range c.npCollector.ScheduleNetworkPathTests(connsIter) {
        if i >= len(scheduledModelConns) { break }
        scheduledModelConns[i].NetworkPath = &model.NetworkPath{HasTest: path.HasTest}
        if path.HasTest {
            scheduledModelConns[i].NetworkPath.TestIdentity = path.TestIdentity
            logNetworkPathConnection(npc, path)
        }
        i++
    }
}

@dd-octo-sts

dd-octo-sts Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the past 15 days.

It will be closed in 30 days if no further activity occurs. If this pull request is still relevant, adding a comment or pushing new commits will keep it open. Also, you can always reopen the pull request if you missed the window.

Thank you for your contributions!

@dd-octo-sts dd-octo-sts Bot added the stale label Jul 26, 2026
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