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

Fix process agent status provider #22527

Merged
merged 9 commits into from
Feb 5, 2024

Conversation

GustavoCaso
Copy link
Member

@GustavoCaso GustavoCaso commented Feb 2, 2024

What does this PR do?

Fix the for the incident 24978

Make sure to write the status result to the correct map.

I added unit test to make sure we do not introduce a similar regression in the future.

Motivation

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

PLEASE TAKE INTO CONSIDERATION THAT THE ORDER OF THE STATUS OUTPUT HAS CHANGED. When doing the QA, we need to focus on the same information being displayed and not too much on order.

Build the agent binary invoke agent.build --build-exclude=systemd

Test that the agent status CLI command returns the right information.

  • JSON format agent status -j
  • Pretty JSON format agent status -p
  • Text format agent status
  • Text format with the verbose flag agent status -v

The agent status displays information about other agent processes if they are running. For testing those permutations, you can build the other agent and run them + modify the agent configuration.

To build and run the process agent, follow this guide
To build the APM agent, run: inv -e trace-agent.build . To run the apm agent ./bin/trace-agent/trace-agent --config dev/dist/datadog.yaml

Here is an example of a configuration with logs, apm and process agent enabled:

api_key: <YOUR API KEY>
site: <YOUR SITE>

logs_enabled: true
apm_config:
  enabled: true
  apm_non_local_traffic: true
process_config:
  process_collection:
    enabled: true

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided. Except if the qa/skip-qa label, with required either qa/done or qa/no-code-change labels, are applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • If applicable, the config template has been updated.

@pr-commenter
Copy link

pr-commenter bot commented Feb 2, 2024

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: 3bedd8f6-a8a4-4f77-a92a-bc06a915a031
Baseline: dae7c3b
Comparison: e9e2919
Total CPUs: 7

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

No significant changes in experiment optimization goals

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

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Experiments ignored for regressions

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

perf experiment goal Δ mean % Δ mean % CI
idle memory utilization +0.02 [-0.02, +0.05]
file_to_blackhole % cpu utilization -0.44 [-7.01, +6.14]
file_tree memory utilization -1.00 [-1.09, -0.92]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
process_agent_standard_check memory utilization +0.56 [+0.49, +0.62]
uds_dogstatsd_to_api_cpu % cpu utilization +0.47 [-0.99, +1.93]
idle memory utilization +0.02 [-0.02, +0.05]
trace_agent_json ingress throughput +0.02 [-0.01, +0.04]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.06, +0.06]
uds_dogstatsd_to_api ingress throughput -0.00 [-0.03, +0.03]
trace_agent_msgpack ingress throughput -0.00 [-0.02, +0.01]
tcp_syslog_to_blackhole ingress throughput -0.02 [-0.08, +0.04]
process_agent_standard_check_with_stats memory utilization -0.18 [-0.23, -0.14]
file_to_blackhole % cpu utilization -0.44 [-7.01, +6.14]
process_agent_real_time_mode memory utilization -0.54 [-0.59, -0.50]
file_tree memory utilization -1.00 [-1.09, -0.92]
otel_to_otel_logs ingress throughput -1.43 [-2.16, -0.70]

Explanation

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".

@GustavoCaso GustavoCaso added this to the 7.52.0 milestone Feb 2, 2024
@GustavoCaso GustavoCaso added [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card qa/done QA done before merge and regressions are covered by tests labels Feb 2, 2024
@GustavoCaso GustavoCaso marked this pull request as ready for review February 2, 2024 17:31
@GustavoCaso GustavoCaso requested a review from a team February 2, 2024 17:31
Copy link
Contributor

@kkhor-datadog kkhor-datadog left a comment

Choose a reason for hiding this comment

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

comp/process/status/statusimpl/status_test.go Outdated Show resolved Hide resolved
Comment on lines +96 to +101
addressPort, err := config.GetProcessAPIAddressPort()
if err != nil {
status["error"] = fmt.Sprintf("%v", err.Error())
return status
}
url = fmt.Sprintf("http://%s/agent/status", addressPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 thought
Wonder if you could mock the config.GetProcessAPIAddressPort instead of setting the testServerURL. I'd rather use an interface and mock it in test.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a totally valid point. I would like to do that in a separate PR, as GetProcessAPIAddressPort is used in multiple places and I don't want to change the focus of the fix in the PR 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see config is global, ok then !

@GustavoCaso
Copy link
Member Author

/trigger-ci

@dd-devflow
Copy link

dd-devflow bot commented Feb 5, 2024

🚂 Gitlab pipeline started

Started pipeline #27696975

@GustavoCaso GustavoCaso added changelog/no-changelog and removed [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card qa/done QA done before merge and regressions are covered by tests labels Feb 5, 2024
@GustavoCaso GustavoCaso force-pushed the fix-process-agent-status-provider branch from 12bc6ed to 3535cbe Compare February 5, 2024 12:40
@@ -209,7 +35,13 @@ func fakeStatusServer(t *testing.T, errCode int, response string) *httptest.Serv
}

func TestStatus(t *testing.T) {
server := fakeStatusServer(t, 200, jsonResponse)
jsonBytes, err := fixturesTemplates.ReadFile("fixtures/json_response.tmpl")
Copy link
Contributor

Choose a reason for hiding this comment

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

💬 suggestion
You can directly embed the two files using

//go:embed fixtures/json_response.json
jsonResponse string // or []bytes if you prefer to have it in bytes

It saves you from an error checking and the double ReadFile

Copy link
Member Author

@GustavoCaso GustavoCaso Feb 5, 2024

Choose a reason for hiding this comment

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

Nice 😄
Thanks for the suggestion

@GustavoCaso
Copy link
Member Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 5, 2024

🚂 MergeQueue

Pull request added to the queue.

There are 3 builds ahead! (estimated merge in less than 1h)

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit 070f8d1 into main Feb 5, 2024
165 checks passed
@dd-mergequeue dd-mergequeue bot deleted the fix-process-agent-status-provider branch February 5, 2024 18:14
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.

3 participants