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

Replace logger config template with strings #34346

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

pgimalac
Copy link
Member

@pgimalac pgimalac commented Feb 24, 2025

What does this PR do?

Refactor seelog config string generation to avoid using a template.

Motivation

Using templates disables some dead code elimination, making binaries around 30% bigger.
We have other uses in the agent so this wouldn't improve existing binaries, but some POC of small processes would be impacted, eg. #34085.

Describe how you validated your changes

Added tests comparing the previously expected config strings with the ones currently generated.
The test cases were generated on the previous implementation, then run on the new one, the output was the same except for a single difference:

- <custom name="syslog" formatid="syslog-&#34;&#39;&lt;a&amp;b&gt;&#39;&#34;" data-uri="%22%27%3ca&amp;b%3e%27%22" data-tls="true" />
+ <custom name="syslog" formatid="syslog-&#34;&#39;&lt;a&amp;b&gt;&#39;&#34;" data-uri="&#34;&#39;&lt;a&amp;b&gt;&#39;&#34;" data-tls="true" />

The special characters in data-uri are encoded differently, this is because they were previously encoded for HTML but are now encoded for XML.
https://docs.oracle.com/cd/A97335_02/apps.102/bc4j/developing_bc_projects/obcCustomXml.htm lists the special characters in XML.

Possible Drawbacks / Trade-offs

Additional Notes

@pgimalac pgimalac added changelog/no-changelog qa/done QA done before merge and regressions are covered by tests team/agent-runtimes labels Feb 24, 2025
@pgimalac pgimalac requested a review from a team as a code owner February 24, 2025 10:08
@pgimalac pgimalac requested a review from misteriaud February 24, 2025 10:08
@github-actions github-actions bot added the short review PR is simple enough to be reviewed quickly label Feb 24, 2025
Copy link

cit-pr-commenter bot commented Feb 24, 2025

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: a001d149-4cb7-4c56-968e-55916305600f

Baseline: 47fe5de
Comparison: 6915272
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
uds_dogstatsd_to_api_cpu % cpu utilization +1.26 [+0.31, +2.20] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.09 [-0.69, +0.88] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.02 [-0.77, +0.81] 1 Logs
file_to_blackhole_1000ms_latency_linear_load egress throughput +0.01 [-0.46, +0.48] 1 Logs
uds_dogstatsd_to_api ingress throughput +0.01 [-0.29, +0.32] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.02] 1 Logs
file_to_blackhole_0ms_latency_http1 egress throughput -0.00 [-0.81, +0.81] 1 Logs
file_to_blackhole_0ms_latency_http2 egress throughput -0.00 [-0.82, +0.82] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.01 [-0.64, +0.62] 1 Logs
file_to_blackhole_100ms_latency egress throughput -0.01 [-0.67, +0.65] 1 Logs
file_to_blackhole_0ms_latency egress throughput -0.04 [-0.86, +0.78] 1 Logs
quality_gate_idle memory utilization -0.20 [-0.25, -0.15] 1 Logs bounds checks dashboard
file_tree memory utilization -0.23 [-0.29, -0.17] 1 Logs
quality_gate_logs % cpu utilization -0.33 [-3.28, +2.62] 1 Logs
quality_gate_idle_all_features memory utilization -0.37 [-0.42, -0.32] 1 Logs bounds checks dashboard
tcp_syslog_to_blackhole ingress throughput -0.64 [-0.70, -0.59] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_0ms_latency lost_bytes 10/10
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_0ms_latency_http1 lost_bytes 10/10
file_to_blackhole_0ms_latency_http1 memory_usage 10/10
file_to_blackhole_0ms_latency_http2 lost_bytes 10/10
file_to_blackhole_0ms_latency_http2 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 lost_bytes 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
quality_gate_idle intake_connections 10/10 bounds checks dashboard
quality_gate_idle memory_usage 10/10 bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 bounds checks dashboard
quality_gate_logs intake_connections 10/10
quality_gate_logs lost_bytes 10/10
quality_gate_logs memory_usage 10/10

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_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check lost_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, 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_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.

Copy link
Contributor

@misteriaud misteriaud left a comment

Choose a reason for hiding this comment

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

The logic looks good ! I'm just wonder if it would no be better to use xml.EscapeText instead of HTMLEscsapeString since we are generating XML output.

@pgimalac
Copy link
Member Author

That's a very fair comment, they should do the same but it's probably more correct to use the one from XML 😄

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Feb 24, 2025

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=57046881 --os-family=ubuntu

Note: This applies to commit 6915272

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Feb 24, 2025

Uncompressed package size comparison

Comparison with ancestor 47fe5ded08d505eb2a4ca389b2f9a8693f034527

Diff per package
package diff status size ancestor threshold
datadog-agent-x86_64-rpm 0.04MB ⚠️ 868.97MB 868.93MB 0.50MB
datadog-agent-x86_64-suse 0.04MB ⚠️ 868.97MB 868.93MB 0.50MB
datadog-agent-aarch64-rpm 0.03MB ⚠️ 858.55MB 858.52MB 0.50MB
datadog-agent-amd64-deb 0.02MB ⚠️ 859.17MB 859.16MB 0.50MB
datadog-agent-arm64-deb 0.01MB ⚠️ 848.78MB 848.77MB 0.50MB
datadog-dogstatsd-amd64-deb 0.00MB 39.42MB 39.42MB 0.50MB
datadog-dogstatsd-x86_64-rpm 0.00MB 39.50MB 39.50MB 0.50MB
datadog-dogstatsd-x86_64-suse 0.00MB 39.50MB 39.50MB 0.50MB
datadog-dogstatsd-arm64-deb 0.00MB 37.96MB 37.96MB 0.50MB
datadog-heroku-agent-amd64-deb 0.00MB 443.42MB 443.42MB 0.50MB
datadog-iot-agent-amd64-deb 0.00MB 62.03MB 62.03MB 0.50MB
datadog-iot-agent-x86_64-rpm 0.00MB 62.10MB 62.10MB 0.50MB
datadog-iot-agent-x86_64-suse 0.00MB 62.10MB 62.10MB 0.50MB
datadog-iot-agent-arm64-deb 0.00MB 59.27MB 59.27MB 0.50MB
datadog-iot-agent-aarch64-rpm 0.00MB 59.34MB 59.34MB 0.50MB

Decision

⚠️ Warning

@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Feb 24, 2025

Static quality checks ✅

Please find below the results from static quality gates

Successful checks

Info

Result Quality gate On disk size On disk size limit On wire size On wire size limit
static_quality_gate_agent_deb_amd64 831.09MiB 847.49MiB 201.4MiB 212.33MiB
static_quality_gate_agent_deb_arm64 821.26MiB 836.66MiB 179.83MiB 192.5MiB
static_quality_gate_agent_rpm_amd64 831.16MiB 847.82MiB 204.23MiB 215.76MiB
static_quality_gate_agent_rpm_arm64 821.15MiB 836.66MiB 183.69MiB 194.24MiB
static_quality_gate_agent_suse_amd64 831.07MiB 847.82MiB 204.23MiB 215.76MiB
static_quality_gate_agent_suse_arm64 821.26MiB 836.66MiB 183.69MiB 194.24MiB
static_quality_gate_dogstatsd_deb_amd64 37.67MiB 49.7MiB 9.78MiB 20.6MiB
static_quality_gate_dogstatsd_deb_arm64 36.27MiB 48.1MiB 8.49MiB 19.1MiB
static_quality_gate_dogstatsd_rpm_amd64 37.67MiB 49.7MiB 9.79MiB 20.6MiB
static_quality_gate_dogstatsd_suse_amd64 37.67MiB 49.7MiB 9.79MiB 20.6MiB
static_quality_gate_iot_agent_deb_amd64 59.23MiB 69.0MiB 14.88MiB 24.8MiB
static_quality_gate_iot_agent_deb_arm64 56.6MiB 66.4MiB 12.83MiB 22.8MiB
static_quality_gate_iot_agent_rpm_amd64 59.23MiB 69.0MiB 14.9MiB 24.8MiB
static_quality_gate_iot_agent_rpm_arm64 56.6MiB 66.4MiB 12.85MiB 22.8MiB
static_quality_gate_iot_agent_suse_amd64 59.23MiB 69.0MiB 14.9MiB 24.8MiB
static_quality_gate_docker_agent_amd64 915.52MiB 931.7MiB 307.07MiB 318.67MiB
static_quality_gate_docker_agent_arm64 928.87MiB 944.08MiB 292.14MiB 303.0MiB
static_quality_gate_docker_agent_jmx_amd64 1.09GiB 1.1GiB 382.18MiB 393.75MiB
static_quality_gate_docker_agent_jmx_arm64 1.09GiB 1.1GiB 363.23MiB 373.71MiB
static_quality_gate_docker_dogstatsd_amd64 45.81MiB 57.88MiB 17.28MiB 28.29MiB
static_quality_gate_docker_dogstatsd_arm64 44.46MiB 56.27MiB 16.16MiB 27.06MiB
static_quality_gate_docker_cluster_agent_amd64 264.95MiB 274.78MiB 106.34MiB 116.28MiB
static_quality_gate_docker_cluster_agent_arm64 280.92MiB 290.82MiB 101.19MiB 111.12MiB

@github-actions github-actions bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Feb 24, 2025
Copy link
Contributor

@misteriaud misteriaud left a comment

Choose a reason for hiding this comment

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

LGTM ! Just a left a nit comment

Comment on lines +139 to +143
if *generate {
err := os.WriteFile(expectedFileName, []byte(cfg), 0644)
require.NoError(t, err)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🥜 nitpick: ‏Do we want to keep this and the generate flag since its purpose is to help writing test cases if I understand correctly ? Maybe having it commented

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically you can run go test ./setup/internal/... -generate to regenerate the fixtures if you updated the test cases
By default it just checks that the generated output is the one in the fixtures

I've seen this pattern in https://github.com/uber-go/dig/blob/master/visualize_golden_test.go#L34 and it seems pretty nice to me
You also don't have to change the code to generate the fixtures
I'll add a comment to make that clearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/agent-runtimes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants