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

Use the new inventoryagent component in the status page #20269

Merged
merged 1 commit into from Nov 16, 2023

Conversation

hush-hush
Copy link
Member

@hush-hush hush-hush commented Oct 19, 2023

What does this PR do?

This fix the status page behavior that was broken when inventoryagent was migrated to component (and metadata were no longer displayed in the status page).

This is a followup PR for #20057

Describe how to test/QA your changes

Check that the status page from the CLI, GUI and in the flare contain the same metadata on Linux and Windows (top section).

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 if the qa/skip-qa label is not 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.

@cit-pr-commenter
Copy link

cit-pr-commenter bot commented Oct 19, 2023

Go Package Import Differences

Baseline: 44d37c7
Comparison: a2f23d7

binaryosarchchange
cluster-agentlinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
cluster-agentlinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
cluster-agent-cloudfoundrylinuxamd64
+4, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
cluster-agent-cloudfoundrylinuxarm64
+4, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
process-agentlinuxamd64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
process-agentlinuxarm64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
process-agentwindowsamd64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
process-agentdarwinamd64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
process-agentdarwinarm64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
heroku-process-agentlinuxamd64
+6, -0
+github.com/DataDog/datadog-agent/comp/core/flare/types
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
security-agentlinuxamd64
+5, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional
security-agentlinuxarm64
+5, -0
+github.com/DataDog/datadog-agent/comp/metadata/internal/util
+github.com/DataDog/datadog-agent/comp/metadata/inventoryagent
+github.com/DataDog/datadog-agent/comp/metadata/runner
+github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl
+github.com/DataDog/datadog-agent/pkg/util/optional

@hush-hush hush-hush force-pushed the maxime/fix-status-page-metadata branch from a76278e to 308b18f Compare October 20, 2023 10:58
@hush-hush hush-hush requested review from a team as code owners October 20, 2023 14:01
@hush-hush hush-hush requested review from gbbr and removed request for a team October 20, 2023 14:01
@hush-hush hush-hush force-pushed the maxime/fix-status-page-metadata branch from 308b18f to 4095859 Compare October 20, 2023 14:02
@urseberry
Copy link
Contributor

No documentation impact. Removing documentation team from reviewers.

@urseberry urseberry removed the request for review from a team October 20, 2023 16:59
@hush-hush hush-hush force-pushed the maxime/fix-status-page-metadata branch from 4095859 to 3c729ef Compare October 24, 2023 09:12
@hush-hush hush-hush force-pushed the maxime/comp-invenotory-host branch 2 times, most recently from a9f7193 to a1d8138 Compare October 25, 2023 15:13
@hush-hush hush-hush force-pushed the maxime/fix-status-page-metadata branch from 3c729ef to adba1fb Compare October 25, 2023 15:22
@pr-commenter
Copy link

pr-commenter bot commented Oct 25, 2023

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: 7493ba06-befa-4b9c-8676-5e7c4a215931
Baseline: 44d37c7
Comparison: a2f23d7
Total datadog-agent CPUs: 7

Explanation

A regression test is an integrated performance test for datadog-agent in a repeatable rig, with varying configuration for datadog-agent. What follows is a statistical summary of a brief datadog-agent run for each configuration across SHAs given above. The goal of these tests are to determine quickly if datadog-agent performance is changed and to what degree by a pull request.

Because a target's optimization goal performance in each experiment will vary somewhat each time it is run, we can only estimate mean differences in optimization goal relative to the baseline target. We express these differences as a percentage change relative to the baseline target, denoted "Δ mean %". These estimates are made to a precision that balances accuracy and cost control. We represent this precision as a 90.00% confidence interval denoted "Δ mean % CI": there is a 90.00% chance that the true value of "Δ mean %" is in that interval.

We decide whether a change in performance is a "regression" -- a change worth investigating further -- if both of the following two criteria are true:

  1. The estimated |Δ mean %| ≥ 5.00%. This criterion intends to answer the question "Does the estimated change in mean optimization goal performance have a meaningful impact on your customers?". We assume that when |Δ mean %| < 5.00%, the impact on your customers is not meaningful. We also assume that a performance change in optimization goal is worth investigating whether it is an increase or decrease, so long as the magnitude of the change is sufficiently large.

  2. Zero is not in the 90.00% confidence interval "Δ mean % CI" about "Δ mean %". This statement is equivalent to saying that there is at least a 90.00% chance that the mean difference in optimization goal is not zero. This criterion intends to answer the question, "Is there a statistically significant difference in mean optimization goal performance?". It also means there is no more than a 10.00% chance this criterion reports a statistically significant difference when the true difference in mean optimization goal is zero -- a "false positive". We assume you are willing to accept a 10.00% chance of inaccurately detecting a change in performance when no true difference exists.

The table below, if present, lists those experiments that have experienced a statistically significant change in mean optimization goal performance between baseline and comparison SHAs with 90.00% confidence OR have been detected as newly erratic. Negative values of "Δ mean %" mean that baseline is faster, whereas positive values of "Δ mean %" mean that comparison is faster. Results that do not exhibit more than a ±5.00% change in their mean optimization goal are discarded. An experiment is erratic if its coefficient of variation is greater than 0.1. The abbreviated table will be omitted if no interesting change is observed.

No interesting changes in experiment optimization goals with confidence ≥ 90.00% and |Δ mean %| ≥ 5.00%.

Fine details of change detection per experiment.
experiment goal Δ mean % Δ mean % CI confidence
tcp_syslog_to_blackhole ingress throughput +0.51 [+0.38, +0.64] 100.00%
file_tree egress throughput +0.23 [-1.65, +2.11] 16.04%
process_agent_standard_check_with_stats egress throughput +0.23 [-1.81, +2.27] 14.71%
idle egress throughput +0.06 [-2.48, +2.59] 2.91%
file_to_blackhole egress throughput +0.05 [-0.97, +1.07] 6.26%
process_agent_standard_check egress throughput +0.03 [-3.53, +3.58] 0.98%
trace_agent_msgpack ingress throughput +0.02 [-0.10, +0.15] 23.89%
dogstatsd_string_interner_8MiB_50k ingress throughput +0.01 [-0.05, +0.06] 19.15%
tcp_dd_logs_filter_exclude ingress throughput +0.01 [-0.15, +0.16] 5.11%
dogstatsd_string_interner_8MiB_100 ingress throughput +0.00 [-0.13, +0.13] 4.28%
dogstatsd_string_interner_64MiB_100 ingress throughput +0.00 [-0.14, +0.14] 0.12%
dogstatsd_string_interner_128MiB_100 ingress throughput -0.00 [-0.14, +0.14] 0.02%
dogstatsd_string_interner_64MiB_1k ingress throughput -0.00 [-0.13, +0.13] 0.25%
trace_agent_json ingress throughput -0.00 [-0.14, +0.13] 0.66%
dogstatsd_string_interner_128MiB_1k ingress throughput -0.00 [-0.14, +0.14] 0.67%
dogstatsd_string_interner_8MiB_1k ingress throughput -0.01 [-0.10, +0.09] 9.38%
dogstatsd_string_interner_8MiB_10k ingress throughput -0.01 [-0.09, +0.07] 13.84%
uds_dogstatsd_to_api ingress throughput -0.02 [-0.19, +0.15] 13.92%
dogstatsd_string_interner_8MiB_100k ingress throughput -0.03 [-0.09, +0.02] 70.41%
process_agent_real_time_mode egress throughput -0.16 [-2.67, +2.35] 8.34%
otel_to_otel_logs ingress throughput -0.26 [-1.83, +1.30] 21.85%

inventoryagent.Module,
// inventoryagent require a serializer. Since we're not actually sending the payload to
// the backend a nil will work.
fx.Provide(func() serializer.MetricSerializer {
Copy link
Contributor

Choose a reason for hiding this comment

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

If another component needs a real serializer the code will panic.
Ideally, can inventoryagent be split into components so that the component you need for flare doesn't use the serializer?
Otherwise, can you return Optional[serializer.MetricSerializer] and use that inside inventory (As serializer is optional) so that another component that would need a MetricSerializer will not crash? What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

As decided during our daily, I'll afdress this in another PR 👍

comp/core/flare/flare.go Outdated Show resolved Hide resolved
func (ia *inventoryagent) Get() map[string]interface{} {
data := map[string]interface{}{}
for k, v := range ia.data {
data[k] = v
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it OK if this function shallow copies ia.data because v can be a map[string]interface{} which is a reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we explicitly call this out in the Set method docstring.

}
checks := s["runnerStats"].(map[string]interface{})["Checks"].(map[string]interface{})
stats := make(map[string]interface{})
stats = getRunnerStats(stats)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why you call getRunnerStats instead of GetStatus(false)?

Copy link
Member Author

@hush-hush hush-hush Nov 10, 2023

Choose a reason for hiding this comment

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

This part only uses the runner part of the stats, so instead of requesting everything and needing to retrieve the metadata we only request what we need. This way we don't need to pass a ref to the inventory metadata payload.

Copy link
Member

Choose a reason for hiding this comment

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

@@ -157,7 +156,8 @@ func GetCheckStatus(c check.Check, cs *checkstats.Stats) ([]byte, error) {

// GetDCAStatus grabs the status from expvar and puts it into a map
func GetDCAStatus(verbose bool) (map[string]interface{}, error) {
stats, err := getCommonStatus()
// inventory is not enabled for the clusteragent/DCA so we pass nil to getCommonStatus
stats, err := getCommonStatus(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it will be great to use Optional[Component] instead of nil. The benefit of using Optional[Component] is that you can assume every component is not nil. It can be tricky to know if a component can be nil or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

After discussing this we will fix this in another PR to not block the fix.

@hush-hush hush-hush force-pushed the maxime/comp-invenotory-host branch 2 times, most recently from a97658a to 10b657d Compare November 10, 2023 15:59
@hush-hush hush-hush force-pushed the maxime/fix-status-page-metadata branch from bce7cbb to 5175090 Compare November 10, 2023 16:02
@hush-hush hush-hush requested review from a team as code owners November 15, 2023 10:41
@hush-hush hush-hush changed the base branch from maxime/comp-invenotory-host to main November 15, 2023 10:46
@hush-hush hush-hush removed request for a team and gbbr November 15, 2023 10:46
Copy link
Member

@GustavoCaso GustavoCaso left a comment

Choose a reason for hiding this comment

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

LGTM

@hush-hush hush-hush modified the milestones: 7.51.0, 7.50.0 Nov 16, 2023
@hush-hush hush-hush merged commit b8e5aa4 into main Nov 16, 2023
153 of 158 checks passed
@hush-hush hush-hush deleted the maxime/fix-status-page-metadata branch November 16, 2023 14:25
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.

None yet

6 participants