Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NDMII-2360] Replace the profile map with a profile provider #31210

Merged
merged 7 commits into from
Dec 11, 2024

Conversation

dplepage-dd
Copy link
Contributor

What does this PR do?

This PR changes the SNMP check to use a profile.Provider type for looking up profiles instead of a plain map[string]ProfileConfig. The overall behavior of the integration shouldn't change, as the only implementation of Provider in this PR is a static one that just provides profiles from a map[string]ProfileConfig.

Motivation

This is part of converting the SNMP integration to receive profiles via Remote Configuration - the first step is ensuring that profiles are fetched from a controlled source instead of being redundantly cached in a variety of places, so that I can add a new Provider type that listens for RC updates and rebuilds the internal configuration mapping.

Describe how to test/QA your changes

Unit tests have been updated; the behavior of the agent shouldn't change.

@dplepage-dd dplepage-dd requested a review from a team as a code owner November 18, 2024 22:38
@dplepage-dd dplepage-dd changed the title Replace the profile map with a profile provider. [NDMII-2360] [Profile Editor][RC] Implement Agent consuming Profiles from RC Nov 18, 2024
@dplepage-dd dplepage-dd changed the title [NDMII-2360] [Profile Editor][RC] Implement Agent consuming Profiles from RC [NDMII-2360] Replace the profile map with a profile provider Nov 18, 2024
@github-actions github-actions bot added team/ndm-core long review PR is complex, plan time to review it labels Nov 18, 2024
@dplepage-dd dplepage-dd added changelog/no-changelog qa/done QA done before merge and regressions are covered by tests labels Nov 19, 2024
@dplepage-dd dplepage-dd changed the base branch from main to dpl/move-test November 19, 2024 03:45
@github-actions github-actions bot added medium review PR review might take time and removed long review PR is complex, plan time to review it labels Nov 19, 2024
Copy link

cit-pr-commenter bot commented Nov 19, 2024

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 9454df83-e95a-497d-93f7-cfcc1ed2a6fb

Baseline: 681517f
Comparison: 6ad5b9d
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
basic_py_check % cpu utilization +2.68 [-1.28, +6.64] 1 Logs
quality_gate_idle_all_features memory utilization +1.42 [+1.29, +1.54] 1 Logs bounds checks dashboard
file_tree memory utilization +1.22 [+1.07, +1.36] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.43 [-0.37, +1.23] 1 Logs
otel_to_otel_logs ingress throughput +0.30 [-0.40, +1.00] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.09 [-0.67, +0.85] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput +0.03 [-0.43, +0.50] 1 Logs
file_to_blackhole_300ms_latency egress throughput +0.02 [-0.61, +0.66] 1 Logs
uds_dogstatsd_to_api ingress throughput +0.00 [-0.10, +0.10] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.02 [-0.75, +0.71] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.10 [-1.01, +0.81] 1 Logs
quality_gate_idle memory utilization -0.49 [-0.54, -0.45] 1 Logs bounds checks dashboard
pycheck_lots_of_tags % cpu utilization -0.70 [-4.08, +2.69] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -0.74 [-1.47, -0.00] 1 Logs
tcp_syslog_to_blackhole ingress throughput -0.93 [-1.00, -0.86] 1 Logs

Bounds Checks: ❌ Failed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_0ms_latency lost_bytes 8/10
file_to_blackhole_500ms_latency lost_bytes 9/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency_linear_load 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_300ms_latency lost_bytes 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features 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".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.

Base automatically changed from dpl/move-test to main November 19, 2024 21:09
@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 Nov 26, 2024
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Nov 27, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv aws.create-vm --pipeline-id=50868614 --os-family=ubuntu

Note: This applies to commit e1c9a66

Copy link
Member

@FlorianVeaux FlorianVeaux left a comment

Choose a reason for hiding this comment

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

The PR looks great to me, nice job on it !
I've just left a few questions and naming questions

@@ -331,15 +330,15 @@ func (d *DeviceCheck) detectMetricsToMonitor(sess session.Session) error {
if err != nil {
return fmt.Errorf("failed to fetch sysobjectid: %s", err)
}
profile, err := profile.GetProfileForSysObjectID(d.config.Profiles, sysObjectID)
profile, err := d.config.Profiles.GetProfileNameForSysObjectID(sysObjectID)
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a custom GetProfileForSysObjectID instead ?
This avoid the repetition of getting the profile name, then getting the profile with a potential error which should never happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behavior right now is:

  1. If a profile name is hard-coded in the config, we set .ProfileName when the config is loaded
  2. When we start looking for metrics, if there isn't a hard-coded profile, we fetch the sysobjectid and then set .ProfileName to the name of the profile that best matches the sysobjectid.
  3. In both cases, after setting .ProfileName, we fetch the profile in question from the provider and recompute config.OidConfig based on it.

So if we want to fetch the profile directly instead of having the name as an intermediate step, we'll still need to handle the case where it's been hardcoded in the config.

Now that I think about it, though, it would be a good idea to do that - we shouldn't be caching the name of the best matching profile, because the best match could change when RC updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this change proved a little complicated, so I'm going to put it in a separate PR (I'm removing the caching fields .Metrics, .MetricTags, .ProfileTags, .Metadata, and .OidConfig from the CheckConfig type and making them a separate object that is held by the DeviceCheck and recomputed when it detects that the sysobjectid or the profile manager has changed).

pkg/collector/corechecks/snmp/internal/profile/profile.go Outdated Show resolved Hide resolved
}

func (s *staticProvider) GetAllProfiles() ProfileConfigMap {
return s.configMap
Copy link
Member

Choose a reason for hiding this comment

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

❓ question: ‏There's a slight risk here (and in GetProfile) that the caller can modify the content of the profiles. Did you see it and would you think it's worth to mitigate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For GetAllProfiles it seemed excessive to clone them all; now that we don't have that anymore, it's just GetProfile that has this risk. I didn't want to copy them because I thought it would be wasteful to copy a profile every time we access it, but maybe that's just me thinking too much like a Python programmer - probably the time needed to duplicate a profile is tiny enough that we can just go ahead and do it every time. Do you think it would be better to just duplicate the profile every time GetProfile() is called?

@agent-platform-auto-pr
Copy link
Contributor

Package size comparison

Comparison with ancestor 3c882e71c8b1830d40be8d4cfae580e40414d207

Diff per package
package diff status size ancestor threshold
datadog-agent-amd64-deb -0.01MB 1265.85MB 1265.86MB 140.00MB
datadog-iot-agent-amd64-deb -0.02MB 113.26MB 113.28MB 10.00MB
datadog-dogstatsd-amd64-deb 0.00MB 78.41MB 78.41MB 10.00MB
datadog-heroku-agent-amd64-deb -0.03MB 526.62MB 526.65MB 70.00MB
datadog-agent-x86_64-rpm -0.01MB 1275.09MB 1275.10MB 140.00MB
datadog-agent-x86_64-suse -0.01MB 1275.09MB 1275.10MB 140.00MB
datadog-iot-agent-x86_64-rpm -0.02MB 113.33MB 113.35MB 10.00MB
datadog-iot-agent-x86_64-suse -0.02MB 113.33MB 113.35MB 10.00MB
datadog-dogstatsd-x86_64-rpm 0.00MB 78.49MB 78.49MB 10.00MB
datadog-dogstatsd-x86_64-suse 0.00MB 78.49MB 78.49MB 10.00MB
datadog-agent-arm64-deb -0.02MB 1000.85MB 1000.87MB 140.00MB
datadog-iot-agent-arm64-deb -0.02MB 108.74MB 108.77MB 10.00MB
datadog-dogstatsd-arm64-deb 0.00MB 55.64MB 55.64MB 10.00MB
datadog-agent-aarch64-rpm -0.02MB 1010.06MB 1010.08MB 140.00MB
datadog-iot-agent-aarch64-rpm -0.02MB 108.81MB 108.84MB 10.00MB

Decision

✅ Passed

@dplepage-dd
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Dec 11, 2024

Devflow running: /merge

View all feedbacks in Devflow UI.


2024-12-11 22:08:42 UTC ℹ️ MergeQueue: pull request added to the queue

The median merge time in main is 26m.


2024-12-11 22:34:53 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit aee886d into main Dec 11, 2024
223 checks passed
@dd-mergequeue dd-mergequeue bot deleted the dpl/dynamic-profiles branch December 11, 2024 22:34
@github-actions github-actions bot added this to the 7.62.0 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog long review PR is complex, plan time to review it qa/done QA done before merge and regressions are covered by tests team/ndm-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants