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 new UnmarshalKey in a few locations. Fix edge cases. #29225

Merged
merged 16 commits into from
Sep 24, 2024

Conversation

dustmop
Copy link
Contributor

@dustmop dustmop commented Sep 11, 2024

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 return its internal data as a map[interface{}]interface{}. 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 PR also changes the new UnmarshalKey implementation to be case-insensitive, as is required by the config.

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
  • Implicitly converting an empty string into an empty slice requires ConvertEmptyStringToNil

Motivation

Improving the config API

Additional Notes

Possible Drawbacks / Trade-offs

It's possible more edge cases exist and this new UnmarshalKey subtly changes semantics, any such changes should be considered bugs.

Describe how to test/QA your changes

Behavior is covered by unit tests, behavior should be identical to before.

Some edge cases are fixed. In order to narrow and simplify the API of the config, only allow these edge case behaviors if certain Options are passed to UnmarshalKey.

UnmarshalKey behavior changes:

- The mapstructure "squash" feature requires EnableSquash
- Case sensitive field matching is always allowed, might become an Option
- Empty strings can be parsed as empty lists, might become an Option
Copy link

cit-pr-commenter bot commented Sep 11, 2024

Go Package Import Differences

Baseline: bb34457
Comparison: b2f7390

binaryosarchchange
agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
iot-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
iot-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
heroku-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
cluster-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
cluster-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
cluster-agent-cloudfoundrylinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
cluster-agent-cloudfoundrylinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
dogstatsdlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
dogstatsdlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
process-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
process-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
process-agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
process-agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
process-agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
heroku-process-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
security-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
security-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
serverlesslinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
serverlesslinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
system-probelinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
system-probelinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
system-probewindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
trace-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
trace-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
trace-agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
trace-agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
trace-agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure
heroku-trace-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/config/structure

@dustmop dustmop added team/agent-shared-components changelog/no-changelog qa/done Skip QA week as QA was done before merge and regressions are covered by tests and removed team/agent-metrics-logs labels Sep 17, 2024
@dustmop dustmop added this to the 7.59.0 milestone Sep 17, 2024
@dustmop dustmop marked this pull request as ready for review September 18, 2024 13:54
@dustmop dustmop requested review from a team as code owners September 18, 2024 13:54
@pr-commenter
Copy link

pr-commenter bot commented Sep 18, 2024

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 b2f7390

Copy link
Contributor

@remeh remeh left a comment

Choose a reason for hiding this comment

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

LGTM from APR perspective, just left one comment.

@@ -133,6 +163,31 @@ feature:
assert.Equal(t, feature.Enabled, true)
}

type FeatureConfigDiffCase struct {
ENaBLEd bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to test a private field as well, maybe not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that would be good. There's another PR in the work to specifically add more test coverage that @jeremy-hanna is working on. Private fields just simply be ignored by the unmarshaller.

Comment on lines 58 to 78
// features allowed for handling edge-cases

type featureSet struct {
allowSquash bool
convertEmptyStrNil bool
}

// UnmarshalKeyOption is an option that affects the enabled features in UnmarshalKey
type UnmarshalKeyOption func(*featureSet)

// EnableSquash allows UnmarshalKey to take advantage of `mapstructure`s `squash` feature
// a squashed field hoists its fields up a level in the marshalled representation and directly embeds them
var EnableSquash UnmarshalKeyOption = func(fs *featureSet) {
fs.allowSquash = true
}

// ConvertEmptyStringToNil allows UnmarshalKey to implicitly convert empty strings into nil slices
var ConvertEmptyStringToNil UnmarshalKeyOption = func(fs *featureSet) {
fs.convertEmptyStrNil = true
}

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Should we move it above the UnmarshalKey function definition?

I always find easier to check for type definitions and var definitions in the top level of the file or above the function they are used.

// skip any additional specifiers such as ",omitempty" or ",squash"
// TODO: support multiple specifiers
var specifiers map[string]struct{}
if commaPos := strings.IndexRune(tagtext, ','); commaPos != -1 {
Copy link
Member

Choose a reason for hiding this comment

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

Question: Could there be more than one comma in a field tag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, leaving a comment above TODO: support multiple specifiers for now. I think implementing this could wait for a future PR as it's a slightly larger change.

@@ -111,3 +112,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure
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 move the replace directive with the rest of replace directives?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, missed this one, yes it should be fixed.

@@ -97,3 +98,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure
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 move the replace directive with the rest of replace directives?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@GustavoCaso
Copy link
Member

Are you planning on replacing the rest of Datadog().UnmarshalKey usage on a separate PR?

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.

Awesome work 🎉

Left a few nit and questions 😄

This comment has been minimized.

@dustmop
Copy link
Contributor Author

dustmop commented Sep 23, 2024

Are you planning on replacing the rest of Datadog().UnmarshalKey usage 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.

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@gh123man gh123man left a comment

Choose a reason for hiding this comment

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

AML owned files LGTM

Copy link
Member

@amenasria amenasria left a comment

Choose a reason for hiding this comment

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

LGTM for Agent DevX Infra owned file !

@@ -598,6 +599,7 @@ require (
github.com/DataDog/datadog-agent/comp/core/tagger/utils v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/def v0.56.0-rc.3
github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/impl v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we're using v0.0.0-00010101000000-000000000000 instead of v0.57.0 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is that v0.0.0-00010101000000-000000000000 is a special version for new modules (this one was added in #28821) that don't have a released version yet. Because we're using replace directives, the build system will use the version from the source repo anyway.

Copy link
Contributor

📥 📢 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.

Copy link
Contributor

Serverless Benchmark Results

BenchmarkStartEndInvocation comparison between 49ca38e and 5e2962e.

tl;dr

Use these benchmarks as an insight tool during development.

  1. Skim down the vs base column 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.

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

// skip any additional specifiers such as ",omitempty" or ",squash"
// TODO: support multiple specifiers
var specifiers map[string]struct{}
if commaPos := strings.IndexRune(tagtext, ','); commaPos != -1 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, leaving a comment above TODO: support multiple specifiers for now. I think implementing this could wait for a future PR as it's a slightly larger change.

@@ -111,3 +112,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, missed this one, yes it should be fixed.

@@ -133,6 +163,31 @@ feature:
assert.Equal(t, feature.Enabled, true)
}

type FeatureConfigDiffCase struct {
ENaBLEd bool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that would be good. There's another PR in the work to specifically add more test coverage that @jeremy-hanna is working on. Private fields just simply be ignored by the unmarshaller.

@@ -97,3 +98,5 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/DataDog/datadog-agent/pkg/config/structure => ../../../pkg/config/structure
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -598,6 +599,7 @@ require (
github.com/DataDog/datadog-agent/comp/core/tagger/utils v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/def v0.56.0-rc.3
github.com/DataDog/datadog-agent/comp/otelcol/ddflareextension/impl v0.0.0-00010101000000-000000000000
github.com/DataDog/datadog-agent/pkg/config/structure v0.0.0-00010101000000-000000000000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is that v0.0.0-00010101000000-000000000000 is a special version for new modules (this one was added in #28821) that don't have a released version yet. Because we're using replace directives, the build system will use the version from the source repo anyway.

source, err := newNode(reflect.ValueOf(cfg.Get(key)))
rawval := cfg.Get(key)
// Don't create a reflect.Value out of nil, just return immediately
if rawval == nil {
Copy link
Contributor Author

@dustmop dustmop Sep 24, 2024

Choose a reason for hiding this comment

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

setupAutoDiscovery in cmd/agent/common/autodiscovery.go expects a nil config setting to return no error. Adding this fix gets the new-e2e-aml test to pass.

@dustmop
Copy link
Contributor Author

dustmop commented Sep 24, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Sep 24, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 23m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit f15628d into main Sep 24, 2024
249 checks passed
@dd-mergequeue dd-mergequeue bot deleted the dustin.long/unmarshalkey-usages branch September 24, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog qa/done Skip QA week as QA was done before merge and regressions are covered by tests team/agent-shared-components
Projects
None yet
Development

Successfully merging this pull request may close these issues.