datadog-agent
datadog-agent copied to clipboard
Use new UnmarshalKey in a few locations. Fix edge cases.
What does this PR do?
This PR begins using the new UnmarshalKey method, which was implemented by #28821, in a few callsites selected arbitrarily. The old UnmarshalKey worked by using yaml.Unmarshal and mapstructure.Unmarshal which each relied on the config being able to operate on map[interface{}]interface{} types. We want to break that assumption in the config, to use a new node-based approach. The new UnmarshalKey uses this approach and is implemented purely using reflection.
This new method should have the same functionality as the old one, but at the same time we want to shrink the config's API and simplify its semantics. For call-sites that rely on edge-case behaviors, that behavior is opted into using an Option.
Edge cases:
- The mapstructure "squash" feature requires EnableSquash
- Case sensitive field matching is always allowed, might become an Option
Motivation
Improving the config
Additional Notes
Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
Go Package Import Differences
Baseline: bb344575821d101433bfb3f146cb716da994f2b8 Comparison: b2f7390ec96b49c4528fe7d0634eae6d49c33c01
| binary | os | arch | change |
|---|---|---|---|
| agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| agent | windows | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| agent | darwin | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| agent | darwin | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| iot-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| iot-agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| heroku-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| cluster-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| cluster-agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| cluster-agent-cloudfoundry | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| cluster-agent-cloudfoundry | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| dogstatsd | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| dogstatsd | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| process-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| process-agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| process-agent | windows | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| process-agent | darwin | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| process-agent | darwin | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| heroku-process-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| security-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| security-agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| serverless | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| serverless | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| system-probe | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| system-probe | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| system-probe | windows | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| trace-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| trace-agent | linux | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| trace-agent | windows | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| trace-agent | darwin | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| trace-agent | darwin | arm64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
| heroku-trace-agent | linux | amd64 | +1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
|
Test changes on VM
Use this command from test-infra-definitions to manually test this PR changes on a VM:
inv create-vm --pipeline-id=45031842 --os-family=ubuntu
Note: This applies to commit b2f7390e
Regression Detector
Regression Detector Results
Run ID: 13d869a9-ebb4-4ac8-9293-2da670bf01ee Metrics dashboard Target profiles
Baseline: bb344575821d101433bfb3f146cb716da994f2b8 Comparison: b2f7390ec96b49c4528fe7d0634eae6d49c33c01
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.
Fine details of change detection per experiment
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | otel_to_otel_logs | ingress throughput | +0.87 | [+0.06, +1.67] | 1 | Logs |
| ➖ | file_tree | memory utilization | +0.36 | [+0.27, +0.45] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api_cpu | % cpu utilization | +0.26 | [-0.48, +1.00] | 1 | Logs |
| ➖ | tcp_syslog_to_blackhole | ingress throughput | +0.18 | [+0.13, +0.23] | 1 | Logs |
| ➖ | tcp_dd_logs_filter_exclude | ingress throughput | -0.00 | [-0.01, +0.01] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api | ingress throughput | -0.01 | [-0.09, +0.08] | 1 | Logs |
| ➖ | idle | memory utilization | -0.43 | [-0.48, -0.39] | 1 | Logs |
| ➖ | basic_py_check | % cpu utilization | -0.49 | [-3.14, +2.17] | 1 | Logs |
| ➖ | pycheck_lots_of_tags | % cpu utilization | -3.16 | [-5.64, -0.69] | 1 | Logs |
Bounds Checks
| perf | experiment | bounds_check_name | replicates_passed |
|---|---|---|---|
| ✅ | idle | memory_usage | 10/10 |
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:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
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.
-
Its configuration does not mark it "erratic".
Are you planning on replacing the rest of Datadog().UnmarshalKey usage on a separate PR?
:inbox_tray: :loudspeaker: Info, this pull request increases the binary size of serverless extension by 29056 bytes. Each MB of binary size increase means about 10ms of additional cold start time, so this pull request would increase cold start time by 0ms.
Debug info
If you have questions, we are happy to help, come visit us in the #serverless slack channel and provide a link to this comment.
We suggest you consider adding the !serverless build tag to remove any new dependencies not needed in the serverless extension.
Are you planning on replacing the rest of
Datadog().UnmarshalKeyusage on a separate PR?
Yes. The hope is to get a few usages in place, and catch any problems that may be caused by any unintended changes in behavior. Eventually all of the uses of UnmarshalKey will switch over and we can remove the old function.
:inbox_tray: :loudspeaker: Info, this pull request increases the binary size of serverless extension by 29056 bytes. Each MB of binary size increase means about 10ms of additional cold start time, so this pull request would increase cold start time by 0ms.
Debug info
If you have questions, we are happy to help, come visit us in the #serverless slack channel and provide a link to this comment.
We suggest you consider adding the !serverless build tag to remove any new dependencies not needed in the serverless extension.
:inbox_tray: :loudspeaker: Info, this pull request increases the binary size of serverless extension by 29056 bytes. Each MB of binary size increase means about 10ms of additional cold start time, so this pull request would increase cold start time by 0ms.
Debug info
If you have questions, we are happy to help, come visit us in the #serverless slack channel and provide a link to this comment.
We suggest you consider adding the !serverless build tag to remove any new dependencies not needed in the serverless extension.
:inbox_tray: :loudspeaker: Info, this pull request increases the binary size of serverless extension by 29056 bytes. Each MB of binary size increase means about 10ms of additional cold start time, so this pull request would increase cold start time by 0ms.
Debug info
If you have questions, we are happy to help, come visit us in the #serverless slack channel and provide a link to this comment.
We suggest you consider adding the !serverless build tag to remove any new dependencies not needed in the serverless extension.
Serverless Benchmark Results
BenchmarkStartEndInvocation comparison between 49ca38e2f6c5d18125df2200f5ce7c9eae8cb175 and 5e2962e791fed15ad339377edc5e6ec86e23c276.
tl;dr
Use these benchmarks as an insight tool during development.
-
Skim down the
vs basecolumn in each chart. If there is a~, then there was no statistically significant change to the benchmark. Otherwise, ensure the estimated percent change is either negative or very small. -
The last row of each chart is the
geomean. Ensure this percentage is either negative or very small.
What is this benchmarking?
The BenchmarkStartEndInvocation compares the amount of time it takes to call the start-invocation and end-invocation endpoints. For universal instrumentation languages (Dotnet, Golang, Java, Ruby), this represents the majority of the duration overhead added by our tracing layer.
The benchmark is run using a large variety of lambda request payloads. In the charts below, there is one row for each event payload type.
How do I interpret these charts?
The charts below comes from benchstat. They represent the statistical change in duration (sec/op), memory overhead (B/op), and allocations (allocs/op).
The benchstat docs explain how to interpret these charts.
Before the comparison table, we see common file-level configuration. If there are benchmarks with different configuration (for example, from different packages), benchstat will print separate tables for each configuration.
The table then compares the two input files for each benchmark. It shows the median and 95% confidence interval summaries for each benchmark before and after the change, and an A/B comparison under "vs base". ... The p-value measures how likely it is that any differences were due to random chance (i.e., noise). The "~" means benchstat did not detect a statistically significant difference between the two inputs. ...
Note that "statistically significant" is not the same as "large": with enough low-noise data, even very small changes can be distinguished from noise and considered statistically significant. It is, of course, generally easier to distinguish large changes from noise.
Finally, the last row of the table shows the geometric mean of each column, giving an overall picture of how the benchmarks changed. Proportional changes in the geomean reflect proportional changes in the benchmarks. For example, given n benchmarks, if sec/op for one of them increases by a factor of 2, then the sec/op geomean will increase by a factor of ⁿ√2.
I need more help
First off, do not worry if the benchmarks are failing. They are not tests. The intention is for them to be a tool for you to use during development.
If you would like a hand interpreting the results come chat with us in #serverless-agent in the internal DataDog slack or in #serverless in the public DataDog slack. We're happy to help!
Benchmark stats
goos: linux
goarch: amd64
pkg: github.com/DataDog/datadog-agent/pkg/serverless/daemon
cpu: AMD EPYC 7763 64-Core Processor
│ baseline/benchmark.log │ current/benchmark.log │
│ sec/op │ sec/op vs base │
api-gateway-appsec.json 90.27µ ± 13% 90.98µ ± 6% ~ (p=0.853 n=10)
api-gateway-kong-appsec.json 68.93µ ± 3% 70.08µ ± 1% ~ (p=0.143 n=10)
api-gateway-kong.json 69.24µ ± 3% 69.99µ ± 3% ~ (p=0.529 n=10)
api-gateway-non-proxy-async.json 106.7µ ± 3% 113.0µ ± 2% +5.88% (p=0.000 n=10)
api-gateway-non-proxy.json 111.2µ ± 2% 109.0µ ± 2% -1.96% (p=0.005 n=10)
api-gateway-websocket-connect.json 74.87µ ± 2% 72.53µ ± 1% -3.12% (p=0.000 n=10)
api-gateway-websocket-default.json 66.40µ ± 1% 66.66µ ± 1% ~ (p=0.218 n=10)
api-gateway-websocket-disconnect.json 66.47µ ± 2% 66.69µ ± 1% ~ (p=0.529 n=10)
api-gateway.json 120.7µ ± 2% 121.7µ ± 1% ~ (p=0.143 n=10)
application-load-balancer.json 67.69µ ± 2% 69.29µ ± 2% +2.37% (p=0.003 n=10)
cloudfront.json 51.59µ ± 1% 51.68µ ± 1% ~ (p=0.796 n=10)
cloudwatch-events.json 41.37µ ± 2% 41.81µ ± 3% ~ (p=0.105 n=10)
cloudwatch-logs.json 68.75µ ± 2% 69.38µ ± 1% ~ (p=0.063 n=10)
custom.json 33.01µ ± 1% 33.95µ ± 1% +2.85% (p=0.000 n=10)
dynamodb.json 97.90µ ± 5% 99.60µ ± 1% ~ (p=0.143 n=10)
empty.json 31.34µ ± 2% 31.75µ ± 4% +1.31% (p=0.015 n=10)
eventbridge-custom.json 50.55µ ± 3% 51.66µ ± 1% +2.19% (p=0.000 n=10)
eventbridge-no-bus.json 49.01µ ± 2% 50.89µ ± 2% +3.84% (p=0.000 n=10)
eventbridge-no-timestamp.json 49.21µ ± 2% 49.33µ ± 2% ~ (p=0.631 n=10)
http-api.json 76.01µ ± 1% 77.51µ ± 2% +1.97% (p=0.004 n=10)
kinesis-batch.json 74.47µ ± 2% 76.86µ ± 1% +3.20% (p=0.000 n=10)
kinesis.json 57.90µ ± 1% 58.25µ ± 1% ~ (p=0.315 n=10)
s3.json 61.64µ ± 3% 62.32µ ± 2% ~ (p=0.529 n=10)
sns-batch.json 96.03µ ± 1% 97.16µ ± 2% ~ (p=0.165 n=10)
sns.json 71.12µ ± 2% 69.73µ ± 1% -1.96% (p=0.000 n=10)
snssqs.json 115.3µ ± 2% 119.8µ ± 2% +3.90% (p=0.001 n=10)
snssqs_no_dd_context.json 104.2µ ± 2% 106.4µ ± 1% +2.09% (p=0.011 n=10)
sqs-aws-header.json 59.03µ ± 2% 59.35µ ± 2% ~ (p=0.436 n=10)
sqs-batch.json 99.24µ ± 4% 102.45µ ± 2% +3.24% (p=0.029 n=10)
sqs.json 76.59µ ± 3% 73.54µ ± 1% -3.98% (p=0.000 n=10)
sqs_no_dd_context.json 70.30µ ± 3% 67.40µ ± 2% -4.14% (p=0.000 n=10)
stepfunction.json 53.59µ ± 2% 51.15µ ± 3% -4.57% (p=0.000 n=10)
geomean 69.01µ 69.55µ +0.78%
│ baseline/benchmark.log │ current/benchmark.log │
│ B/op │ B/op vs base │
api-gateway-appsec.json 37.27Ki ± 0% 37.34Ki ± 0% +0.18% (p=0.000 n=10)
api-gateway-kong-appsec.json 26.93Ki ± 0% 26.94Ki ± 0% ~ (p=0.810 n=10)
api-gateway-kong.json 24.43Ki ± 0% 24.44Ki ± 0% ~ (p=0.838 n=10)
api-gateway-non-proxy-async.json 48.08Ki ± 0% 48.15Ki ± 0% +0.15% (p=0.000 n=10)
api-gateway-non-proxy.json 47.31Ki ± 0% 47.36Ki ± 0% +0.11% (p=0.000 n=10)
api-gateway-websocket-connect.json 25.52Ki ± 0% 25.54Ki ± 0% +0.10% (p=0.000 n=10)
api-gateway-websocket-default.json 21.42Ki ± 0% 21.45Ki ± 0% +0.16% (p=0.000 n=10)
api-gateway-websocket-disconnect.json 21.20Ki ± 0% 21.23Ki ± 0% +0.12% (p=0.000 n=10)
api-gateway.json 49.61Ki ± 0% 49.62Ki ± 0% ~ (p=0.239 n=10)
application-load-balancer.json 22.39Ki ± 0% 23.33Ki ± 0% +4.21% (p=0.000 n=10)
cloudfront.json 17.68Ki ± 0% 17.70Ki ± 0% +0.11% (p=0.001 n=10)
cloudwatch-events.json 11.72Ki ± 0% 11.76Ki ± 0% +0.27% (p=0.000 n=10)
cloudwatch-logs.json 53.39Ki ± 0% 53.40Ki ± 0% ~ (p=0.402 n=10)
custom.json 9.757Ki ± 0% 9.774Ki ± 0% +0.18% (p=0.014 n=10)
dynamodb.json 40.80Ki ± 0% 40.84Ki ± 0% ~ (p=0.148 n=10)
empty.json 9.328Ki ± 0% 9.346Ki ± 0% ~ (p=0.055 n=10)
eventbridge-custom.json 15.05Ki ± 0% 15.06Ki ± 0% ~ (p=0.172 n=10)
eventbridge-no-bus.json 14.02Ki ± 0% 14.05Ki ± 0% +0.19% (p=0.027 n=10)
eventbridge-no-timestamp.json 14.04Ki ± 0% 14.06Ki ± 1% ~ (p=0.393 n=10)
http-api.json 23.87Ki ± 0% 23.94Ki ± 0% +0.29% (p=0.001 n=10)
kinesis-batch.json 27.11Ki ± 0% 27.16Ki ± 0% +0.17% (p=0.000 n=10)
kinesis.json 17.92Ki ± 0% 17.92Ki ± 0% ~ (p=0.591 n=10)
s3.json 20.39Ki ± 1% 20.45Ki ± 0% ~ (p=0.218 n=10)
sns-batch.json 38.84Ki ± 0% 38.83Ki ± 0% ~ (p=0.811 n=10)
sns.json 24.17Ki ± 0% 24.11Ki ± 0% ~ (p=0.085 n=10)
snssqs.json 50.73Ki ± 0% 50.81Ki ± 0% +0.15% (p=0.001 n=10)
snssqs_no_dd_context.json 44.94Ki ± 0% 45.03Ki ± 0% +0.19% (p=0.009 n=10)
sqs-aws-header.json 18.92Ki ± 1% 18.89Ki ± 1% ~ (p=0.684 n=10)
sqs-batch.json 41.76Ki ± 0% 41.84Ki ± 1% ~ (p=0.393 n=10)
sqs.json 25.72Ki ± 0% 25.63Ki ± 1% -0.35% (p=0.012 n=10)
sqs_no_dd_context.json 20.93Ki ± 1% 20.85Ki ± 1% ~ (p=0.280 n=10)
stepfunction.json 14.35Ki ± 1% 14.37Ki ± 1% ~ (p=0.912 n=10)
geomean 24.46Ki 24.51Ki +0.20%
│ baseline/benchmark.log │ current/benchmark.log │
│ allocs/op │ allocs/op vs base │
api-gateway-appsec.json 629.5 ± 0% 630.0 ± 0% ~ (p=1.000 n=10)
api-gateway-kong-appsec.json 488.0 ± 0% 488.0 ± 0% ~ (p=1.000 n=10) ¹
api-gateway-kong.json 466.0 ± 0% 466.0 ± 0% ~ (p=1.000 n=10)
api-gateway-non-proxy-async.json 726.0 ± 0% 726.0 ± 0% ~ (p=1.000 n=10)
api-gateway-non-proxy.json 716.0 ± 0% 716.0 ± 0% ~ (p=1.000 n=10)
api-gateway-websocket-connect.json 453.5 ± 0% 453.0 ± 0% -0.11% (p=0.033 n=10)
api-gateway-websocket-default.json 379.0 ± 0% 380.0 ± 0% ~ (p=0.370 n=10)
api-gateway-websocket-disconnect.json 370.0 ± 0% 370.0 ± 0% ~ (p=1.000 n=10)
api-gateway.json 791.0 ± 0% 791.0 ± 0% ~ (p=1.000 n=10)
application-load-balancer.json 352.0 ± 0% 353.0 ± 0% +0.28% (p=0.000 n=10)
cloudfront.json 284.0 ± 0% 284.0 ± 0% ~ (p=1.000 n=10) ¹
cloudwatch-events.json 221.0 ± 0% 221.0 ± 0% ~ (p=0.303 n=10)
cloudwatch-logs.json 216.0 ± 0% 216.0 ± 0% ~ (p=1.000 n=10)
custom.json 169.0 ± 0% 169.0 ± 0% ~ (p=1.000 n=10)
dynamodb.json 589.0 ± 0% 589.5 ± 0% ~ (p=1.000 n=10)
empty.json 160.0 ± 0% 160.0 ± 0% ~ (p=1.000 n=10)
eventbridge-custom.json 267.0 ± 0% 267.0 ± 0% ~ (p=0.628 n=10)
eventbridge-no-bus.json 258.0 ± 0% 258.0 ± 0% ~ (p=0.381 n=10)
eventbridge-no-timestamp.json 258.0 ± 0% 258.5 ± 1% ~ (p=1.000 n=10)
http-api.json 434.0 ± 0% 434.0 ± 0% ~ (p=0.837 n=10)
kinesis-batch.json 392.0 ± 0% 392.0 ± 0% ~ (p=0.365 n=10)
kinesis.json 287.0 ± 0% 286.0 ± 0% -0.35% (p=0.005 n=10)
s3.json 358.0 ± 1% 359.0 ± 0% ~ (p=0.646 n=10)
sns-batch.json 457.0 ± 0% 457.0 ± 0% ~ (p=1.000 n=10)
sns.json 325.5 ± 0% 324.0 ± 0% ~ (p=0.113 n=10)
snssqs.json 440.0 ± 0% 440.5 ± 0% ~ (p=0.314 n=10)
snssqs_no_dd_context.json 401.0 ± 0% 402.0 ± 0% ~ (p=0.278 n=10)
sqs-aws-header.json 274.5 ± 1% 274.5 ± 1% ~ (p=0.906 n=10)
sqs-batch.json 504.5 ± 0% 506.0 ± 1% ~ (p=0.317 n=10)
sqs.json 353.0 ± 1% 351.5 ± 1% -0.42% (p=0.008 n=10)
sqs_no_dd_context.json 328.0 ± 1% 326.5 ± 1% ~ (p=0.179 n=10)
stepfunction.json 239.0 ± 1% 238.5 ± 1% ~ (p=0.559 n=10)
geomean 363.8 363.8 -0.01%
¹ all samples are equal
/merge
:steam_locomotive: MergeQueue: pull request added to the queue
The median merge time in main is 23m.
Use /merge -c to cancel this operation!