Fix unexpected behavior when multiple file sinks used with agent #5610
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As I was trying out the
auto_auth
feature of the agent, I noticed there was some strange behavior with the file sinks. Specifically, I used the agent with the following configuration file:One would expect that this would create two file sinks: one file named
file-foo
that is encrypted, and another namedfile-bar
with just a token in plain text.file-bar
was indeed just a plain text token, as expected. However,file-foo
looked like this:In other words, it was TTL-wrapped, but not encrypted. However, when I reverse the order of the file sinks in the configuration file so that it now looks as shown below, things were equally weird.
After restarting the agent with this config file,
file-foo
now looks like this:while
file-bar
looks like this:It appeared to me that the nature of this issue lie in this block so I fixed it to reference only the first argument to the
sinkFunc
rather than thes
. With this change, it seems that the agent writes to sinks as expected -file-bar
will be plain-text client token, whilefile-foo
will be an encrypted token, regardless of the order in which they appear in the config file.